


How can a network expert not understand these Linux 'network configuration' and 'troubleshooting' commands?
1. ifconfig
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 IP address and gateway
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 or disable specific network ports
enable
ordisable
, we use the example command as follows.
启用 eth0
# ifup eth0
Disable eth0
# ifdown eth0
Set MTU size
By default the
MTU
size is1500
. We can set the desiredMTU
size with the following command. ReplaceXXXX
with size.
# ifconfig eth0 mtu XXXX
Set the interface to promiscuous mode
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
2. ping command
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
3. traceroute command
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
4. netstat command
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
5. dig command
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
6. nslookup command
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
7. route command
route` command also displays and manipulates the `ip` routing table. View the default routing table`LinuxCopy after login
#route
Use the following commands to add, delete routes and default gateways.
Add route
# route add -net 10.10.10.0/24 gw 192.168.0.1
Delete route
# route del -net 10.10.10.0/24 gw 192.168.0.1
Add default gateway
# route add default gw 192.168.0.1
8. host command
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.
9. arp command
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
10. ethtool command
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
11. iwconfig command
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.
12. hostname command
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

VS Code is available on Mac. It has powerful extensions, Git integration, terminal and debugger, and also offers a wealth of setup options. However, for particularly large projects or highly professional development, VS Code may have performance or functional limitations.

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

VS Code is the full name Visual Studio Code, which is a free and open source cross-platform code editor and development environment developed by Microsoft. It supports a wide range of programming languages and provides syntax highlighting, code automatic completion, code snippets and smart prompts to improve development efficiency. Through a rich extension ecosystem, users can add extensions to specific needs and languages, such as debuggers, code formatting tools, and Git integrations. VS Code also includes an intuitive debugger that helps quickly find and resolve bugs in your code.

Visual Studio Code (VSCode) is a cross-platform, open source and free code editor developed by Microsoft. It is known for its lightweight, scalability and support for a wide range of programming languages. To install VSCode, please visit the official website to download and run the installer. When using VSCode, you can create new projects, edit code, debug code, navigate projects, expand VSCode, and manage settings. VSCode is available for Windows, macOS, and Linux, supports multiple programming languages and provides various extensions through Marketplace. Its advantages include lightweight, scalability, extensive language support, rich features and version

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.
