linux的网络命令整理 更新中
1.安装包:
net-tools 主要命令: netstat , ifconfig , route , iptunnel
iproute 主要命令: ss , ip addr , ip route , ip tunnel
2.net-tools 系列主要用法:
netstat
#查看本机开启的 tcp[-t] udp[-u] 监听[-l] 端口,以数字形式[-n] ,显示PID|进程名称 [-p]
# netstat -tunlp
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 25/httpd
ifconfig
#查看本机网络ip信息
#ifconfig eth0
eth0: flags=4163 mtu 1500
inet 172.17.0.2 netmask 255.255.0.0 broadcast 0.0.0.0
ether 02:42:ac:11:00:02 txqueuelen 0 (Ethernet)
RX packets 5344 bytes 7795340 (7.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1157 bytes 78876 (77.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
route
#查看本机路由信息
#route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default gateway 0.0.0.0 UG 0 0 0 eth0
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
iptunnel
NULL
3.iproute 系列主要用法:
ss
#查看本机开启的 tcp4[-t4] 监听[-l] 端口,以数字形式[-n] 显示
# ss -ln -t4
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
tcp LISTEN 0 128 *:80 *:*
ip addr
#查看本机网络ip信息
# ip addr
34: eth0: mtu 1500 qdisc noqueue state UP
link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.2/16 scope global eth0
valid_lft forever preferred_lft forever
ip route
#查看本机路由信息
# ip route
default via 172.17.0.1 dev eth0
172.17.0.0/16 dev eth0 proto kernel scope link src 172.17.0.2
ip tunnel
NULL
#