1:netstate[弃用]

netstat的作用:

1:网络连接netstat -ass
2:路由表netstat -rip route
3:统计接口netstat -vip -s link
4:伪连接netstat -Mss
5:组播成员netstat -gip maddr

2:ss:Socket Statistics :获取socket统计信息

1:查询ss是否安装
[root@localhost ~]# rpm -qf /usr/sbin/ss
iproute-3.10.0-13.el7.x86_64
[root@localhost ~]# rpm -q iproute
iproute-3.10.0-13.el7.x86_64


2:查看当前服务器的网络连接统计
[root@localhost ~]# ss -s
Total: 434 (kernel 459)
TCP:   6 (estab 2, closed 0, orphaned 0, synrecv 0, timewait 0/0), ports 0

Transport Total     IP        IPv6
*         459       -         -
RAW       1         0         1
UDP       2         2         0
TCP       6         4         2
INET      9         6         3
FRAG      0         0         0

3:查看所有打开的网络端口
[root@localhost ~]# ss -l
[root@localhost ~]# ss -pl | grep sshd           ### -p列出具体的程序名称
tcp    LISTEN     0      128                  *:ssh                   *:*        users:(("sshd",1618,3))
tcp    LISTEN     0      128                 :::ssh                  :::*        users:(("sshd",1618,4))

###   1618为pid

4:查看这台服务器的所有socket连接
[root@localhost ~]# ss -a
[root@localhost ~]# ss -ta|ua|wa|xa     ### TCP/UDP/RAW/UNIX sockets

3:net-tools与iproute2对比

展示本机所有网络接口ifconfigip link show
2:开启某给网络接口ifconfig eth0 upip link set up eth0
3:停止某个网络接口ifconfig eth0 downip link set down eth0
4:给网络接口设置网络Ip地址ifconfig eth0 10.0.0.1/24ip addr add 10.0.0.1/24 dev eth0
5:删除网络Ip地址ifconfig eth0 0ip addr del 10.0.0.1/24 dev eth0
6:显示某个网络接口的IP地址ifconfig eth0ip addr show dev eth0
7:显示路由表route -nip route show
8:添加默认网关route add default gw 192.168.1.2 eth0ip route add default via 192.168.1.2 eth0
9:删除默认网关route del default gw 192.168.1.2 eth0ip route del default via 192.168.1.2 eth0
10:展示arp表arp -anip neigh
11:添加ARP项arp -s 192.168.1.100
00 :0c:29:c0:5d:ef
ip neigh add 192.168.1.100 lladdr
00 :0c:29:c0:5d:ef
12:删除arp项arp -d 192.168.1.100ip neigh del 192.168.1.100 dev eth0
13:查看组播信息ipmaddr show dev eth0ip maddr list dev eth0 ###注意格式
14:展示socket状态netstat -lss -l

查看man帮助,详细信息

[root@localhost ~]# man ip route

12-27 10:01
查看更多