linux的網絡命令整理 更新中

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<UP,BROADCAST,RUNNING,MULTICAST>  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: <BROADCAST,MULTICAST,UP,LOWER_UP> 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


#

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章