Network management
View network status tool
1.net-tools
- ifconfig
- route
- netstat
2.iproute2
- ip
- ss
# Ifconfig card information display
- eth0 first NIC (network interface)
- The first network interface can be called the following names
- eno1 onboard NIC
- ens33 PCI-E card
- enp0s3 Unable to get physical PCI-E card information
- centos7 using the network device naming consistency, none of the above match is used eth0
The network interface name modification
NIC naming biosdevname and net.ifnames by two parameters affect, edit / etc / default / grup file, add biosdevname = 0 net.ifnames = 0, can make the card name changed back to eth0
After the above two parameters to modify, update grub, modify the network card name
# grup2-mkconfig -o /boot/grub2/grub.cfg into a readable file system
reboot
# reboot
biosdevname | net.ifnames | Name card | |
---|---|---|---|
default | 0 | 1 | ens33 |
Combination 1 | 1 | 0 | em1 |
Combination 2 | 0 | 0 | eth0 |
Glossary: GRUB Boot Manager is a multi-system, which is responsible for loading the kernel and boot Linux system, the first program to run at system startup is grub.
Path GRUB configuration file / etc / default / grub
Check the physical connection card
- mii-tool eth0
View Gateway
- route -n Use the -n parameter does not resolve the host name, so faster, if + ip, ip will resolve to the domain name, more slowly
Network configuration commands
- ifconfig <Interface> <IP address> [Subnet Mask]
- ifup <Interface> Start Interface
- ifdown <Interface> Close Interface
Add the Gateway
- route add default gw <gateway ip>
- route add -host <specify ip> gw <gateway ip>
- route add -net <specify the network segment> netmask <subnet mask> gw <gateway ip>
Gateway with iproute2 tool set
- ip add ls
- ifconfig
- ip link set dev eth0 up
- ifup eth0
- ip addr add 10.0.0.1/24 dev eth1
- ifconfig eth1 10.0.0.1 netmask 255.255.255.0
- ip route add 10.0.0/24 via 192.168.0.1
- route add -net 10.0.0.0 netmask 255.255.255.0 gw 192.168.0.1
Network Troubleshooting Commands
-
ping detecting whether the current communication and destination hosts, the network may be interrupted or fails a firewall, using the ICMP ping instruction transfer protocol
Example
# ping www.baidu.com -
Each trace traceroute routing hops, the packet data to display the path between a host
Example
# traceroute -w 1 www.baidu.com -w set waiting time -
mtr detecting whether packet loss between the current and destination hosts, traceroute detailed than content displayed
Example
# mtr -
See nslookup command corresponding domain ip, check information for DNS
Example
# nslookup www.baidu.com -
telnet connection state of the inspection port
Example
# telnet www.baidu.com 80 -
tcpdump capture, sniffer tool, it can print all the header information packets through network interface
Example
# tcpdump -i any (arbitrary NIC) -n (do not use the domain name display) 80 Port
# tcpdump -n -i the any Host 10.0.0.1
# tcpdump -i -n the any Host 10.0.0.1 and Port 8080
# tcpdump -i -n the any Host 10.0.0.1 and Port 8080 -w / tmp / filenname -
netstat to print status information in Linux network system that lets you know the network of the entire Linux system.
Example
# netstat -ntpl- -n Display IP, domain names do not show
- -t tcp way to intercept unwanted content
- -p display process
- -l listen, listen
-
ss is used to display information in the active state of the socket, able to display more detailed information about the connection state of TCP and, faster and more efficient than netstat
Example
# ss -ntpl
Network Management Services
Network Services Management program is divided into two, namely SysV and systemd
- service network start|stop|restart
- chkconfig -list network
- systemctl list-unit-files NetworkManager.service
- systemctl start|stop|restart NetworkManager
- systemctl enable|disable NetworkManager
systemd Centos7 network service management tools, SysV is Centos6 and previous
Network Configuration File
- ifcfg-eth0 network card configuration file names with real names changed
- / Etc / hosts file configuration associated with the host
NM (NetworkManager.service) can manage a variety of network
- Wired network card, wireless card
- Dynamic ip, static ip
- Ethernet, non-Ethernet
- Physical card, virtual card
nmcli: command line. NM This is the most commonly used tools, Centos8 use the tool to manage network
Some commonly used commands NM
Check ip (similar to ifconfig, ip addr)
nmcli
nmcli connection understood to profile corresponds ifcfg-ethX.
It can be abbreviated as nmcli c
Create a connection, configure the static IP (equivalent to the configuration ifcfg, wherein BOOTPROTO = none, and start ifup)
nmcli the Add C-CON Ethernet type name ifname the ethX ipv4.addr 192.168.1.100/24 ipv4.gateway the ethX 192.168.1.1 ipv4.method Manual
Create a connection, a dynamic IP configuration (equivalent to the configuration ifcfg, wherein BOOTPROTO = dhcp, and start ifup)
nmcli the Add C-CON Ethernet type name Auto ipv4.method the ethX ifname the ethX
IP modified (non-interactive)
nmcli C Modify the ethX ipv4.addr '192.168.1.200/24'
nmcli up the ethX C
修改ip(交互式)
nmcli c edit ethX
nmcli> goto ipv4.addresses
nmcli ipv4.addresses> change
Edit 'addresses' value: 192.168.1.200/24
Do you also want to set 'ipv4.method' to 'manual'? [yes]: yes
nmcli ipv4> save
nmcli ipv4> activate
nmcli ipv4> quit
Enable connection (equivalent to ifup)
nmcli c up ethX
Stop connection (corresponding to ifdown)
nmcli C Down
Delete connection (similar ifdown and remove the ifcfg)
nmcli c the Delete ethX
View connection list
nmcli c show
View connection details
nmcli c show ethX
All ifcfg overloaded or route to the connection (do not take effect immediately)
nmcli c reload
Ifcfg or overloaded designated route to the connection (do not take effect immediately)
nmcli the Load c / etc / sysconfig / Network-scripts / ifcfg-ethX
nmcli the Load c / etc / sysconfig / Network-scripts / route-ethX
Connection to take effect immediately, there are three ways
nmcli c up ethX
nmcli d Reapply ethX
nmcli d Connect ethX
View device list
nmcli d
View all device details
nmcli d show
View the details of the specified device
nmcli d show ethX
Activate the card
nmcli d connect ethX
Turn off the wireless network (NM enabled by default wireless network)
nmcli OFF All r
View NM nanotube state
nmcli n
NM open nanotube
nmcli n on
Close NM nanotube (careful execution)
nmcli the n-OFF
Monitor events
nmcli m
View NM state itself
nmcli
Detecting whether the available online NM
nm-online