0 11 min 2 weeks

  The Linux system itself is designed to have powerful network and communication functions, supporting TCP/IP, ATM, IPX/SPX, X.2.5, Frame-relay, AppleTalk, and other network communication protocols, and integrating the implementation of these protocols into the Linux kernel, providing efficient network communication processing capabilities

  Viewing and testing network configuration is the first step in managing Linux network services

  The network interface card (NIC) of the host is usually called ‘network interface’

  View information of all active network interfaces

  When ifconfig command is used without any options or parameters, it will display the information of the network interfaces that are currently enabled (active) in the host

  View information of all network interfaces

  View the information of the specified network interface

  When you only need to view the information of one network interface, you can use the name of the network interface as a parameter for the ifconfig command, regardless of whether the network interface is active or not

  View the current hostname

  Temporarily modify the current hostname

  [

  Executing the route command directly can display the routing table information in the current host

  The routing table in the Linux system determines the destination of data sent from this host to other hosts and networks, which is a key piece of information for troubleshooting network issues

  Route -n displays the result using IP addresses

  netstat command

  Checking the network connection status, routing table, interface statistics, and other information is an effective tool for understanding network status and troubleshooting network service failures

  Insert image description here
online casino victoryClick to enter
  ss is the abbreviation for Socket Statistics. The ss command is used to display information about active sockets. It can display similar content to netstat. However, the advantage of ss is that it can display more detailed information about TCP and connection states, and it is faster and more efficient than netstat.

  Syntax format: ss [options]

  Insert image description here

  In the early operation and maintenance work, checking the number of server connections generally used the netstat command. In fact, there is a command that is more efficient than netstat, that is the ss (Socket Statistics) command!

  The ss command can be used to obtain socket statistics, and it can display similar content to netstat.

  The advantage of ss is that it can display more detailed information about TCP and connection status, and it is faster and more efficient than netstat. The reasons are as follows:

  1) When the number of socket connections on the server becomes very large, whether using the netstat command or directly cat /proc/net/tcp, the execution speed will be very slow. You may not have a personal feeling, but believe me, when the number of connections maintained by the server reaches tens of thousands, using netstat is a waste of life, while using ss is a time-saver.

  The secret of ss’s speed lies in its use of tcp_diag in the TCP protocol stack. tcp_diag is a module for analysis and statistics that can obtain first-hand information from the Linux kernel, which ensures the quick and efficient operation of ss. Of course, if tcp_diag is not available in your system, ss can still run normally, but the efficiency will be slightly slower (but still faster than netstat).

  Almost all Linux systems will include the netstat command by default, but not all systems will include the ss command by default.

  The netstat command is a member of the net-tools toolset, which is generally pre-installed in Linux systems; the ss command is a member of the iproute toolset;

  net-tools is a set of standard Unix network tools used for configuring network interfaces, setting routing table information, managing ARP tables, displaying and statistics of various network information, etc., but unfortunately, this tool has not been updated or maintained since 2001.

  iproute is a set of tools that can support IPv4/IPv6 networks and is used for managing TCP/UDP/IP networks

  If there is no ss command, you can install it as follows:

  yum install iproute iproute-doc

  2.1: Use the ping command to test network connectivity

  Test network connectivity

  Basic command format

  ping [options] target host

  ‘Press Ctrl C to terminate the ping test’

  ‘Feedback: Target host is unreachable may mean that the target address does not exist or the host is already closed’

  ‘Feedback: Network is unreachable indicates that there are no available routing records, such as gateways, and it is impossible to reach the network where the target host is located’

  ‘Feedback: Request timeout indicates that the data has reached the other side but cannot return’

  Test the network nodes between the current host and the target host

  For nodes that cannot respond, the connection status will be displayed as *

  The traceroute command is more accurate in locating the fault points (break points) of network connections than the ping command, and its execution speed is therefore slower than that of the ping command.

  In network testing, use ping first, if a network connection failure is found, use the traceroute command to track and view the fault node

  Basic command format

  traceroute is suitable for probing local area networks, and wide area networks may be blocked

  nslookup command

  Test DNS domain resolution, resolve the domain name to an IP address

  Ns = name server

  DNS port tcp 53 port function connection to DNS server

  UDP 53 port function resolution

  Basic command format

  Windows 10 display

  Insert image description here

  Insert image description here

  The full name of the dig command is ‘domain information groper’, which is a tool for flexibly querying DNS. It prints out the responses from the DNS domain name server, and the dig command is mainly used to query host address information from the DNS domain name server.

  The dig command is almost the same as the nslookup command, but it is more flexible, easier to use, and has clearer output.

  Syntax format: dig [parameters] [IP]

  Insert image description here

  3.1.1: Temporary configuration: Adjust network parameters using commands

  Temporary modification, usually used for maintenance

  Simple, fast, and can directly modify running network parameters

  Generally, it is only suitable for use during network debugging

  After the system restarts, the modifications will take effect directly

  3.1.2: Fixed settings: Modify network parameters through the configuration file

  Modify the configuration file of various network parameters

  It is suitable for setting fixed parameters for the server

  It needs to reload the network service or restart the system for it to take effect

  Set the IP address and subnet mask of the network interface

  ifconfig interface name IP address [subnet mask subnet mask]

  ifconfig network interface IP address[/subnet mask length]

  Disable or reactivate the network interface

  ifconfig network interface up

  ifconfig network interface down

  For example

  Insert image description here

  Insert image description here

  During the debugging process of the server network, sometimes it is necessary to use a new IP address on the same network card temporarily, but it cannot overwrite the original IP address to make the service program unavailable.

  At this time, a virtual network interface can be bound to the network card, and then a new IP address can be configured for the virtual interface (equivalent to configuring multiple IP addresses for a network card).

  Command format for setting up virtual network interfaces

  ifconfig interface name: serial number IP address

  [root@localhost ~]# ifconfig ens33:0 192.168.200.10/24

  Insert image description here

  The route command can not only be used to view routing table information, but also to add, delete static routing table entries, including setting the default gateway address (the default gateway record is a special static routing entry).

  The IP address of the default gateway should be in the same subnet as one of the IP addresses of the local interface

  3.4.1 Add the routing record to the specified subnet

  3.4.2 Delete the routing record to the specified subnet

  route del -net subnet address

  3.4.3 Delete the default gateway record in the routing table

  Only one default gateway record should be in the routing table of the same host, otherwise it will cause the network understanding of the host to fail

  4.2.1 Restart network network service

  Insert image description here

  /etc/sysconfig/network file, it is in CentOS6 system

  Save global network settings, mainly including host name informationlottery method and Just click to enter

  /etc/hostname file, it is in CentOS7 system

  /etc/resolv.conf file

  Save the IP address of the DNS server that the local machine needs to use

  The modifications made to this file take effect immediately

  In the Linux system, up to 3 different DNS server addresses can be specified (the third and subsequent ones will be ignored), and the first DNS server is used preferentially

  [root@localhost ~]# vim /etc/resolv.conf

  search localdomain ‘Default search domain (domain suffix), that is, when accessing the host localhost, it is equivalent to accessing localhost.localdomain’

  nameserver 100.100.1.30

  nameserver 100.100.100.30

  /etc/hosts file

  Save the mapping records of host name and IP address

  Generally used to save information of frequently accessed hosts

  Comparison between hosts file and DNS server

  By default, the system first looks up the resolution record in the hosts file

  When accessing an unknown domain, first check if there is a corresponding mapping record in this file, and if not found, go to the DNS server for query

  The hosts file only takes effect on the current host
online casino secrets and The latest website
  Because the hosts file is only stored locally

  The hosts file can reduce the DNS query process, thereby speeding up access speed

  Add correct mapping records (frequent websites visited) to the /etc/hosts file, reducing DNS queries and improving internet speed

  Because CentOS 8 has deprecated network.service, the NetworkManager (NM) command is used to enable network cards. Of course, CentOS 8 can install network.service as a network service, but to adapt to the version, this time we still need to introduce the usage of nmcli commands.

  Summary of nmcli common commands based on RHEL8/CentOS8