Table of Contents
1. ifconfig" >1. ifconfig
Assign IP address and gateway" >Assign IP address and gateway
Enable or disable specific network ports" >Enable or disable specific network ports
unsetunset启用 eth0unsetunset" >unsetunset启用 eth0unsetunset
unsetunsetDisable eth0unsetunset" >unsetunsetDisable eth0unsetunset
Set MTU size" >Set MTU size
Set the interface to promiscuous mode" >Set the interface to promiscuous mode
2. ping command" >2. ping command
3. traceroute command" >3. traceroute command
4. netstat command" >4. netstat command
5. dig command" >5. dig command
6. nslookup command" >6. nslookup command
7. route command" >7. route command
unsetunsetAdd routeunsetunset" >unsetunsetAdd routeunsetunset
unsetunsetDelete routeunsetunset" >unsetunsetDelete routeunsetunset
unsetunsetAdd default gatewayunsetunset" >unsetunsetAdd default gatewayunsetunset
8. host command" >8. host command
9. arp command" >9. arp command
10. ethtool command" >10. ethtool command
11. iwconfig command" >11. iwconfig command
12. hostname command" >12. hostname command
Home System Tutorial LINUX How can a network expert not understand these Linux 'network configuration' and 'troubleshooting' commands?

How can a network expert not understand these Linux 'network configuration' and 'troubleshooting' commands?

Mar 18, 2024 pm 04:22 PM
linux linux tutorial linux system linux command shell script embeddedlinux Getting started with linux linux learning

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.

网工高手,哪有不懂这些 Linux ‘网络配置’ 和 ‘故障排除’ 命令的?

# 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
Copy after login

ifconfig With network port (eth0) command only displays specific interface details, such as IP Address, MAC Address, etc. With -a option will show all available interface details if it is also disabled.

# ifconfig eth0
Copy after login

Assign IP address and gateway

Assign an IP Address and Gateway instant interface. If the system is restarted, this setting will be deleted.

# ifconfig eth0 192.168.1.110 netmask 255.255.255.0
Copy after login

Enable or disable specific network ports

enable or disable, we use the example command as follows.

unsetunset启用 eth0unsetunset
# ifup eth0
Copy after login
unsetunsetDisable eth0unsetunset
# ifdown eth0
Copy after login

Set MTU size

By default the MTU size is 1500. We can set the desired MTU size with the following command. Replace XXXX with size.

# ifconfig eth0 mtu XXXX
Copy after login

Set the interface to promiscuous mode

Network interface Only received packets belong to that specific NIC. If you put the interface in promiscuous 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
Copy after login

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
Copy after login

In Linux the ping command is executed until you interrupt it. Ping with -c option after exiting N 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
Copy after login

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 global DNS server IP Address and being able to reach the destination also shows the path that the packet is traveling.

# traceroute 8.8.8.8
Copy after login

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
Copy after login

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
Copy after login

6. nslookup command

The

nslookup command is also used to find DNS related queries. The following example shows A Record (IP Address) of rumenz.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
Copy after login

7. route command

route` command also displays and manipulates the `ip` routing table. View the default routing table`Linux
Copy after login
#route
Copy after login

Use the following commands to add, delete routes and default gateways.

unsetunsetAdd routeunsetunset
# route add -net 10.10.10.0/24 gw 192.168.0.1
Copy after login
unsetunsetDelete routeunsetunset
# route del -net 10.10.10.0/24 gw 192.168.0.1
Copy after login
unsetunsetAdd default gatewayunsetunset
# route add default gw 192.168.0.1
Copy after login

8. host command

host Command to find name IP or IP Name IPv4 or IPv6 and query DNS records.

# host www.rumenz.com
www.rumenz.com has address 42.194.162.109
Copy after login

Using the -t option we can find out the DNS resource records, such as CNAME, 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.
Copy after login

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
Copy after login

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
Copy after login

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.
Copy after login

12. hostname command

hostname is identified in the network. Execute the hostname 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
Copy after login

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What computer configuration is required for vscode What computer configuration is required for vscode Apr 15, 2025 pm 09:48 PM

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)

vscode cannot install extension vscode cannot install extension Apr 15, 2025 pm 07:18 PM

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.

How to run java code in notepad How to run java code in notepad Apr 16, 2025 pm 07:39 PM

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.

Can vscode be used for mac Can vscode be used for mac Apr 15, 2025 pm 07:36 PM

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.

Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

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.

What is vscode What is vscode for? What is vscode What is vscode for? Apr 15, 2025 pm 06:45 PM

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.

How to use VSCode How to use VSCode Apr 15, 2025 pm 11:21 PM

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

How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

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.

See all articles