First, the view and test network
1, the network interface using the ifconfig command to view
(1) View active network interfaces
ifconfig command
(2) View all network interfaces (that have been disabled can be found)
ifconfig -a command
(3) Check the specified network interface (regardless of whether the interface is active)
ifconfig device name
Information (4) ifconfig command contains
[root@localhost ~]# ifconfig eno16777736
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
mtu: MTU on Unit
inet 192.168.100.120 netmask 255.255.255.0 broadcast 192.168.100.255
inet: IP address
netmask: Subnet Mask
broadcast: broadcast address
inet6 fe80 :: 20c: 29ff: fe97 : eb45 prefixlen 64 scopeid 0x20 <link>
inet6: IPv6 Address
ether 00: 0c: 29: 97 : eb: 45 txqueuelen 1000 (Ethernet)
ether: physical address
txqueuelen: transmitting queue length
RX packets 654209 bytes 794202707 (757.4 MiB )
RX packets: receiving a data packet
bytes: the number of bytes received
RX errors 0 dropped 0 overruns 0 frame 0
errors: Error
dropped: discard
overruns: Overload
frame:帧数
TX packets 1286 bytes 114097 (111.4 KiB)
TX packets: data packets sent
bytes: Bytes Sent
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
collisions: collision
2, ip, ethtool command to view network interface
(1) See data link layer of the network interface
ip link command (see the broadcast address and the MAC address MAC address)
(2) See network interface information of the network layer
ip a (ip address) Command
(3) See network interface rate designation information, mode
ethtool command
(4) View Link
mill -tool card name
3, view the host name, routing table
(1) hostname command to view the host name
// hostname hostname temporarily modify the hostname
Displays the host name after bash // modified
(2) routing table
- Use the route command to view the routing table
- Use netstat -r command to view the routing table
- -n (route -n / netstat -rn): do not perform DNS reverse lookup (address resolution is not), directly display the numeric IP address
4, view network connection (network status) command the netstat
(1) common options
-a: displays information about the current host connection for all activities
-n: display information in digital form
-r: Displays routing information
-t: display information related to the TCP protocol
-u: UDP protocol information display
-p: display connected to the network-related process ID, process name information (requires root privileges)
-l: view only in the listening state
(2) Examples
netstat -anpt // view the status of all TCP
netstat -anpu // View all UDP status
5, the test network connectivity ping, traceroute, nslookup command
(1) ping command to test network connectivity
Specifies the number of transmitted packets: -c
-i: ping through, the number of seconds specified interval to send the next data packet
-w: When ping fails, each data packet transmitted over the specified time
-s: Specifies the packet size
(2) routing of packets route tracking
-n: Do not perform a reverse DNS lookup, directly display the numeric IP address
(3) Test DNS name resolution nslookup command
6, common TTL lifetime
windows:128/127
linux:64/63
unix:255
cisco:255
Second, set the network address parameters
1, modify the network card configuration file
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eno16777728
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777728
DEVICE=eno16777728
ONBOOT=yes
IPADDR=192.168.200.112
NETMASK=255.255.255.0
GATEWAY=192.168.200.2
DNS2=202.106.0.20
2, the state temporarily modify the network card
ifconfig card number down && ifconfig card number up
3, reload the configuration file
centos 7:systemct restart network
centos 6:service network restart
Third, modify the hostname
1, the temporary modification
(1) hostname new hostname
bash
(2)hostnamectl set-hostname xxx.com
2, permanently modify the hostname
(1) vim to edit / etc / sysconfig / network configuration file
NETWORKING=YES
HOSTNAME=XXX.amber.com
reboot reboot to take effect
Fourth, configure routing
1, temporary configuration route (temporarily add, delete records of the specified route segment)
(1) route add -net The network / subnet mask gw gateway address short format
(2) route del -net The network / subnet mask short format
route -n
2, add and delete temporary gateway address
(1) route add default gateway address
(2) route del default gateway address
3, permanently configured route
(1)vim /etc/rc.local
route add -net 192.168.200.0/24 dev eth0
systemctl reboot network
(2)vim /etc/sysconfig/network
Fifth, set the DNS name resolution
1, DNS name resolution
(1)vim /etc/sysconfig/network-scripts/ifcfg-eno16777728
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777728
DEVICE=eno16777728
ONBOOT=yes
IPADDR=192.168.200.112
NETMASK=255.255.255.0
GATEWAY=192.168.200.2
DNS2=202.106.0.20
(2)vim /etc/resolv.conf
nameserver 192.168.200.111
DNS1=202.106.0.20
2, DNS local mapping file
(1) vim / etc / hosts (hosts file takes precedence over the DNS domain name resolution services, there is a domain name mapping in hosts, the domain name will no longer be resolved by the DNS service.)