Network protocol
OSI Seven-Layer Model and TCP/IP Four-Layer Model
TCP Protocol and UDP Protocol
- TCP protocol: Transport control protocol. It is a connection-oriented protocol, which must establish a reliable connection with the other party before sending data.
- UDP protocol: User datagram protocol. It is a connectionless transport layer protocol that provides simple and unreliable information delivery services for transactions.
Difference between TCP and UDP
- TCP needs connection, UDP has no connection
- TCP needs more system resources, UDP needs less system resources.
- There are 20 bytes in TCP packet and 8 bytes in UDP packet.
- TCP guarantees data order and UDP guarantees data correctness
Port assignment
service | Port number |
---|---|
sshd | 22 |
DNS | 53 |
web(http) | 80 |
https | 443 |
Three shakes and four waves
The three handshake
- Client sends syn=1 request package to server
- The server receives the request and sends syn=1,ack=1 to return the package.
- The client sends ack=1 back to the server when it receives it.
Connection setup, start transferring files
The four wave.
- Client sends fin=1 request package to server
- Server receives and returns ack=1 to client
- The server sends fin=1,ack=1 to the client
- When the client receives it, it returns ack=1 to the server.
Connection disconnect
Three Network Models
Bridging mode
- In this mode, the virtual machine can connect to the external network.
- Hosts within the LAN can access the virtual machine.
- Virtual machines can communicate with host computers
- Virtual machines can communicate with the same host in the same mode
- The IP address of the virtual machine in bridge mode needs to be kept in the same segment as the IP of the host.
nat mode
- Virtual machines can connect to external networks
- Other hosts in the LAN are not accessible
- Virtual machine IP needs to be consistent with host VMnet8 in ant mode
Host-only mode
- Virtual Machine Can't Connect External Network
Network card configuration
Close Network Manager
[root@freedom ~]# systemctl stop NetworkManager [root@freedom ~]# systemctl disable NetworkManager
Configure NIC
[root@freedom ~]# cd /etc/sysconfig/network-scripts [root@freedom network-scripts]# vim ifcfg-ens33
NAME=ens33
DEVICE=ens33
ONBOOT=yes
BOOTPROTO=static
DNS1=114.172.16.254.110
IPADDR=172.16.105.19
NETMASK=255.255.0.0
GATEWAY=172.16.0.1
[root@freedom network-scripts]# systemctl restart network [root@freedom network-scripts]# ifconfig ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.16.105.19 netmask 255.255.0.0 broadcast 192.16.255.255 [root@freedom network-scripts]# ip address 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:69:28:03 brd ff:ff:ff:ff:ff:ff inet 192.16.105.19/16 brd 192.16.255.255 scope global ens33
View port ss
option
- -t-tcp
- - n: Convert the protocol name to port
- - l: View ports in listening state
- - a: View ports in all States
[root@freedom network-scripts]# ss -tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:111 *:* LISTEN 0 128 *:6000 *:* LISTEN 0 5 192.168.122.1:53 *:* LISTEN 0 128 *:22 *:* LISTEN 0 128 127.0.0.1:631 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 :::111 :::* LISTEN 0 128 :::6000 :::* LISTEN 0 128 :::22 :::* LISTEN 0 128 ::1:631 :::* LISTEN 0 100 ::1:25 :::*
Computer English
manager | Administrators |
enforce | implement |
| | |