Network Management of Linux Learning articles
Port:
Number of ports: 0-2 ^ 16-1 (0-65535) → is limited by TCP and UDP protocol packet headers
FTP:20 21
SSH:22
Telnet:23
DNS:53
HTTP:80 → HTTPS:443
SMTP:25
POP3:110
Netstat-an # lists all current network connection status
-a: lists all connection states, including TCP/UDP/UNIX socket
-n: displays the IP address and port number instead of the hostname and service name
-t: only TCP packet connections are listed
-u: only UDP packet connections are listed
-p: lists the file names of PID and program
-l: lists only the network status of services that are already in Listen (listening)
-c: set to update automatically after a few seconds, for example,-c 5 updates the network status every 5 seconds
Netstat-tulnp # shows the network services that have been started
Netstat-atunp # View the status of all network connections on this computer
IP address configuration:
1) ifconfig command temporarily configure IP address
Ifconfig eth0 192.168.0.200 netmask 255.255.255.0
# temporarily set the IP address and subnet mask of the eth0 Nic
2) the setup tool permanently configures IP addresses
① setup
② vim / etc/sysconfig/network-scripts/ifcfg-eth0
# change ONBOOT=no to ONBOOT=yes
# in this way, the eth0 network card can be activated, otherwise the network card cannot be used
③ service network restart
3) modify the network configuration file
① vim / etc/sysconfig/network-scripts/ifcfg-eth0 # Nic information file (IP address, etc.)
② vim / etc/sysconfig/network # hostname file
Hostname hostname # View and temporarily set hostname
③ vim / etc/resolv.conf # DNS configuration file
4) Supplementary knowledge
Modify UUID:
① vim / etc/sysconfig/network-scripts/ifcfg-eth0
# Delete MAC address line
② rm-rf / etc/udev/rules.d/70-persistent-net.rules
# Delete Nic and MAC address binding file
③ restart the system
Network commands:
Ifconfig command
Ifdown network card device name: # disable the network card
Ifup network card device name: # enable the network card
Netstat-an | grep ESTABLISHED | wc-l # to see how many users are connecting to this server
Netstat-rn or route-n # View routes and gateways
Nslookup domain name # for domain name resolution
Ping
Telnet 192.168.0.252 80
Traceroute domain name or IP # route trace
Wget http://...... # download command
Tcpdump [- AennqX] [- I interface] [- w store file name] [- c times] [- r file] [packet data format to be extracted]
-A: the content of the packet is displayed in ASCII, which is usually used to capture WWW web page packet data.
-e: use MAC packet data from the data link layer (OSI layer 2) to display
-nn: directly displayed in IP and port number instead of hostname and service name
-Q: list only relatively short packet information
-X: the packet contents of hexadecimal (hex) and ASCII can be listed, which is useful for listening on packet contents.
-I: followed by the network port to be monitored, such as eth0,lo, etc.
-w: if you want to store the monitored packet data, use this parameter, followed by the file name
-r: read the packet data from the following file, which is made by-w
-c: if this parameter is not available, tcpdump will listen continuously
Example: tcpdump-I eth0-nn # obtains the data of eth0 network card with IP and port number
Tcpdump-I eth0-nn port 21 # only listens to port 21 data
Tcpdump-I eth0-nn-X 'port 21' # hexadecimal and ASCII view
Tcpdump-I eth0-nn 'port 22 and src host 192.168.1.101'
# snooping eth0, communication port 22, and destination packet source of 192.168.1.101
# it seems to be OK without quotation marks