Home >System Tutorial >LINUX >How can a network expert not understand these Linux 'network configuration' and 'troubleshooting' commands?
In the Linux kernel, the ifconfig command plays an important role in configuring and displaying network interface parameters. Through the ifconfig command, users can perform various configurations on the network interface. However, it should be noted that the network card information configured using the ifconfig command will become invalid once the network card is restarted or the machine is restarted. If you want to save these configuration information permanently in the computer, you need to modify the configuration file of the corresponding network card. In this way, the configuration will be retained even if the system is restarted.
# ifconfig eth0: flags=4163 mtu 1500 inet 172.24.186.123 netmask 255.255.240.0 broadcast 172.24.191.255 ether 00:16:3e:24:5d:8c txqueuelen 1000 (Ethernet) RX packets 36773275 bytes 9755326821 (9.0 GiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 31552596 bytes 6792314542 (6.3 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 loop txqueuelen 1000 (Local Loopback) RX packets 36893510 bytes 27158894604 (25.2 GiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 36893510 bytes 27158894604 (25.2 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ifconfig
With network port (eth0
) command only displays specific interface details, such asIP Address
,MAC Address
, etc. With-a
option will show all available interface details if it is also disabled.
# ifconfig eth0
Assign an
IP Address
andGateway
instant interface. If the system is restarted, this setting will be deleted.
# ifconfig eth0 192.168.1.110 netmask 255.255.255.0
enable
ordisable
, we use the example command as follows.
# ifup eth0
# ifdown eth0
By default the
MTU
size is1500
. We can set the desiredMTU
size with the following command. ReplaceXXXX
with size.
# ifconfig eth0 mtu XXXX
Network interface
Only received packets belong to that specificNIC
. If you put the interface inpromiscuous
mode it will receive all packets. This is useful for capturing packets and analyzing them later. To do this, you may need superuser access.
# ifconfig eth0 - promisc
The ping command is used to test the network connectivity between hosts. Executing the ping command will use the ICMP transport protocol to send a message requesting a response. If there is no problem with the network function of the remote host, it will respond to the message, thus knowing that the host is operating normally.
# ping 127.0.0.1 or # ping www.rumenz.com
In
Linux
the ping command is executed until you interrupt it. Ping with-c
option after exitingN
number of requests (success or error response).
# ping -c 5 www.rumenz.com PING www.rumenz.com (42.194.162.109) 56(84) bytes of data. 64 bytes from 42.194.162.109 (42.194.162.109): icmp_seq=1 ttl=52 time=35.8 ms 64 bytes from 42.194.162.109 (42.194.162.109): icmp_seq=2 ttl=52 time=35.6 ms 64 bytes from 42.194.162.109 (42.194.162.109): icmp_seq=3 ttl=52 time=35.6 ms 64 bytes from 42.194.162.109 (42.194.162.109): icmp_seq=4 ttl=52 time=35.6 ms 64 bytes from 42.194.162.109 (42.194.162.109): icmp_seq=5 ttl=52 time=35.6 ms --- www.rumenz.com ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4004ms rtt min/avg/max/mdev = 35.662/35.720/35.893/0.190 ms
traceroute
is a network troubleshooting utility that displays the number of hops taken to reach a destination, which also determines the path a packet takes. Below we are tracing the route to the globalDNS server IP Address
and being able to reach the destination also shows the path that the packet is traveling.
# traceroute 8.8.8.8
The netstat command is used to print the status information of the network system in Linux, allowing you to know the network status of the entire Linux system.
# netstat -r Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface default gateway 0.0.0.0 UG 0 0 0 eth0 link-local 0.0.0.0 255.255.0.0 U 0 0 0 eth0 172.24.176.0 0.0.0.0 255.255.240.0 U 0 0 0 eth0
dig command is a commonly used domain name query tool, which can be used to test whether the domain name system is working properly.
# dig www.rumenz.com ; > DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.7 > www.rumenz.com ;; global options: cmd ;; Got answer: ;; ->>HEADER#53(100.100.2.136) ;; WHEN: Sat Nov 20 21:45:32 CST 2021 ;; MSG SIZE rcvd: 48
The
nslookup
command is also used to findDNS
related queries. The following example showsA Record
(IP Address
) ofrumenz.com
.
# nslookup www.rumenz.com Server: 100.100.2.136 Address: 100.100.2.136#53 Non-authoritative answer: Name: www.rumenz.com Address: 42.194.162.109
route` command also displays and manipulates the `ip` routing table. View the default routing table`Linux
#route
Use the following commands to add, delete routes and default gateways.
# route add -net 10.10.10.0/24 gw 192.168.0.1
# route del -net 10.10.10.0/24 gw 192.168.0.1
# route add default gw 192.168.0.1
host
Command to find nameIP
orIP
NameIPv4
orIPv6
and queryDNS
records.
# host www.rumenz.com www.rumenz.com has address 42.194.162.109
Using the
-t
option we can find out the DNS resource records, such asCNAME
,NS
,MX
,SOA
etc.
//Install first # yum install bind-utils -y # host -t CNAME www.baidu.com www.baidu.com is an alias for www.a.shifen.com.
The arp command is the Address Resolution Protocol. It is an extremely important network transmission protocol in a network protocol package that finds the data link layer address by parsing the network layer address. This command can display and modify the buffered data in the arp protocol parsing table.
# arp -e Address HWtype HWaddress Flags Mask Iface gateway ether ee:ff:ff:ff:ff:ff C eth0
The ethtool command is used to obtain the configuration information of the Ethernet card, or to modify these configurations. This command is relatively complex and has many functions.
# ethtool eth0 Settings for eth0: Link detected: yes
iwconfig The system configures wireless network devices or displays wireless network device information. The iwconfig command is similar to the ifconfig command, but its configuration object is a wireless network card, which performs wireless operations on network devices, such as setting wireless communication bands
//Install first # yum install -y wireless-tools # iwconfig [interface] eth0 no wireless extensions.
hostname
is identified in the network. Execute thehostname
command to view the hostname of the machine. The hostname can be set permanently in/etc/sysconfig/network
. A reboot is required after setting the correct hostname.
# hostname rumenz.com
The above is the detailed content of How can a network expert not understand these Linux 'network configuration' and 'troubleshooting' commands?. For more information, please follow other related articles on the PHP Chinese website!