查看CentOS 7网络接口信息
ASP站长网查看所有活动网络接口的信息
ifconfig命令
[root@localhost ~]# ifconfig    //查看网络接口信息
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.144.133  netmask 255.255.255.0  broadcast 192.168.144.255
        inet6 fe80::a85a:c203:e2e:3f3c  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:5b:d3:a0  txqueuelen 1000  (Ethernet)
        RX packets 6139  bytes 3599390 (3.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2483  bytes 330519 (322.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
 
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 84  bytes 7500 (7.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 84  bytes 7500 (7.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
 
virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:d9:de:d2  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
查看指定网络接口信息
ifconfig 网络接口
[root@localhost ~]# ifconfig ens33        //查看ens33网络接口信息
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.144.133  netmask 255.255.255.0  broadcast 192.168.144.255
        inet6 fe80::a85a:c203:e2e:3f3c  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:5b:d3:a0  txqueuelen 1000  (Ethernet)
        RX packets 6183  bytes 3602858 (3.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2505  bytes 334073 (326.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
查看主机名称
查看或设置当前主机名
hostname命令
[root@localhost ~]# hostname //查看主机名称
localhost.localdomain
更改主机名称
hostnamectl set-hostname [主机名称]
[root@localhost ~]# hostnamectl set-hostname http01    //更改主机名
[root@localhost ~]# su                 //切换用户,刷新主机名
[root@http01 ~]# hostname           //查看主机名称
http01
查看路由表条目
查看路由表
route命令
[root@http01 ~]# route    //查看路由表
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         gateway         0.0.0.0         UG    100    0        0 ens33
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
192.168.144.0   0.0.0.0         255.255.255.0   U     100    0        0 ens33
查看网络连接情况
查看系统的网络连接状态、路由表、接口统计等信息
 
netstat命令
netstat [选项]
 
常用选项
-a :全部
 
-n:数字格式显示
 
-p:协议
 
-t :tcp
 
-u :udp
 
-r:路由
 
[root@http01 ~]# netstat -antp      //查看以数字格式显示全部TCP协议端口的网络连接情况
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd           
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      1308/dnsmasq        
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      983/sshd            
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      985/cupsd           
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1292/master         
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      4840/sshd: root@pts 
tcp        0      0 192.168.144.133:22      192.168.144.1:54734     ESTABLISHED 4840/sshd: root@pts 
tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd           
tcp6       0      0 :::80                   :::*                    LISTEN      2373/httpd          
tcp6       0      0 :::22                   :::*                    LISTEN      983/sshd            
tcp6       0      0 ::1:631                 :::*                    LISTEN      985/cupsd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      1292/master         
tcp6       0      0 ::1:6010                :::*                    LISTEN      4840/sshd: root@pts
[root@http01 ~]# netstat -nuap         //查看以数字格式显示全部UDP协议端口的网络连接情况
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
udp        0      0 0.0.0.0:36571           0.0.0.0:*                           788/dhclient        
udp        0      0 0.0.0.0:47956           0.0.0.0:*                           578/avahi-daemon: r 
udp        0      0 192.168.122.1:53        0.0.0.0:*                           1308/dnsmasq        
udp        0      0 0.0.0.0:67              0.0.0.0:*                           1308/dnsmasq        
udp        0      0 0.0.0.0:68              0.0.0.0:*                           788/dhclient        
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           578/avahi-daemon: r 
udp        0      0 127.0.0.1:323           0.0.0.0:*                           636/chronyd         
udp6       0      0 :::57996                :::*                                788/dhclient        
udp6       0      0 ::1:323                 :::*                                636/chronyd        
[root@http01 ~]# netstat -r     //查看路由信息,与route命令作用相同
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         gateway         0.0.0.0         UG        0 0          0 ens33
192.168.122.0   0.0.0.0         255.255.255.0   U         0 0          0 virbr0
192.168.144.0   0.0.0.0         255.255.255.0   U         0 0          0 ens33
网络测试连接
测试网络通讯性
 
ping命令
ping [主机名]/[IP地址]
 
[root@http01 ~]# ping 192.168.100.10        //测试网络通讯
PING 192.168.100.10 (192.168.100.10) 56(84) bytes of data.
64 bytes from 192.168.100.10: icmp_seq=1 ttl=128 time=0.860 ms
64 bytes from 192.168.100.10: icmp_seq=2 ttl=128 time=0.530 ms
64 bytes from 192.168.100.10: icmp_seq=3 ttl=128 time=0.514 ms
64 bytes from 192.168.100.10: icmp_seq=4 ttl=128 time=0.465 ms
跟踪数据包
测试从当前主机到目的主机之间经过的网络节点
 
traceroute命令
traceroute 目标主机地址
 
[root@http01 ~]# traceroute 192.168.100.10
traceroute to 192.168.100.10 (192.168.100.10), 30 hops max, 60 byte packets
 1  gateway (192.168.144.2)  0.320 ms  0.255 ms  0.223 ms
 2  * * *
 3  * * *
 4  * * *
域名解析
测试DNS域名解析
 
nslookup命令
nslookup [目标主机地址]/[目标DNS地址]
 
[root@http01 ~]# nslookup www.baidu.com
Server:     192.168.144.2
Address:    192.168.144.2#53
 
Non-authoritative answer:
www.baidu.com   canonical name = www.a.shifen.com.
Name:   www.a.shifen.com
Address: 183.232.231.172
Name:   www.a.shifen.com
Address: 183.232.231.174
设置网络参数的方式
临时配置——使用命令调整网络参数
简单、快速,可直接修改运行中的网络参数
 
一般只适合在调试网络的过程中使用
 
重新启动以后,所做的修改将会失效
固定设置——通过配置文件修改网络参数
修改各项网络参数的配置文件
适合对服务器设置固定参数时使用
需要重载网络服务或者重启以后才会生效

dawei

【声明】:九江站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。