您好,登錄后才能下訂單哦!
常用的網絡管理類工具有哪些,并用示例形式描述他們的使用方法。
ifconfig命令
#ifconfig -a
#ifconfig INTERFACE [up|down]
ifconfiginterface [aftype] options | address ...
#ifconfig INTERFACE IP/mask [up]
#ifconfig INTERFACE IP netmask MASK
route命令
查看:route -n
添加:route add
routeadd [-net|-host] target [netmask Nm] [gw Gw] [[dev] If]
添加:
route add [-net|-host] target [netmask Nm] [gw GW] [[dev] If]
示例:route add-net 10.0.0.0/8 gw 192.168.10.1 dev eth2
route add -net 0.0.0.0/0.0.0.0 gw192.168.10.1
route add default gw 192.168.10.1
刪除:
route del [-net|-host] target [gw Gw] [netmask Nm] [[dev] If]
示例:route del -net 10.0.0.0/8 gw 192.168.10.1
route del default
netstat命令
Printnetwork connections, routing tables, interface statistics, masqueradeconnections, and multicast memberships
顯示路由表:netstat -rn
-r:顯示內核路由表
-n:數字格式
顯示網絡連接:
netstat [--tcp|-t] [--udp|-u] [--udplite|-U] [--sctp|-S] [--raw|-w] [--listening|-l] [--all|-a] [--numeric|-n] [--extend|-e[--extend|-e]] [--program|-p]
-t:TCP協議的相關連接,連接均有其狀態;FSM(Finate State Machine);
-u:UDP相關的連接
-w:raw socket相關的連接
-l:處于監聽狀態的連接
-a:所有狀態
-n:以數字格式顯示IP和Port;
-e:擴展格式
-p:顯示相關的進程及PID;
常用組合:
-tan, -uan, -tnl, -unl, -tunlp
傳輸層協議:
tcp:面向連接的協議;通信開始之前,要建立一個虛鏈路;通信完成后還要拆除連接;
udp:無連接的協議;直接發送數據報文;
顯示接口的統計數據:
netstat {--interfaces|-I|-i} [iface] [--all|-a] [--extend|-e] [--verbose|-v] [--program|-p] [--numeric|-n]
所有接口:
netstat -i
指定接口:
netstat -I<IFace>
ip命令
show/ manipulate routing, devices, policy routing and tunnels
ip[ OPTIONS ] OBJECT { COMMAND | help }
OBJECT:= { link | addr | route | netns }
注意: OBJECT可簡寫,各OBJECT的子命令也可簡寫;
ip OBJECT:
iplink: network device configuration
ip link set - change device attributes
devNAME (default):指明要管理的設備,dev關鍵字可省略;
up和down:
multicaston或multicast off:啟用或禁用多播功能;
nameNAME:重命名接口
mtuNUMBER:設置MTU的大小,默認為1500;
netnsPID:ns為namespace,用于將接口移動到指定的網絡名稱空間;
ip link show - display device attributes
ip link help - 顯示簡要使用幫助;
ip netns: - manage network namespaces.
ip netns list:列出所有的netns
ip netns add NAME:創建指定的netns
ip netns del NAME:刪除指定的netns
ip netns exec NAME COMMAND:在指定的netns中運行命令
ipaddress - protocol address management.
ipaddress add - add new protocol address
ip addr add IFADDR dev IFACE
[labelNAME]:為額外添加的地址指明接口別名;
[broadcastADDRESS]:廣播地址;會根據IP和NETMASK自動計算得到;
[scopeSCOPE_VALUE]:
global:全局可用;
link:接口可用;
host:僅本機可用
ipaddress delete - delete protocol address
ipaddr delete IFADDR dev IFACE
ipaddress show - look at protocol addresses
ip addr list [IFACE]:顯示接口的地址;
ipaddress flush - flush protocol addresses
ip addr flush dev IFACE
ip route 命令
iproute - routing table management
iproute add - add new route
iproute change - change route
iproute replace - change or add new one
ip route add TYPE PREFIX via GW [dev IFACE] [src SOURCE_IP]
示例:
#ip route add 192.168.0.0/24 via10.0.0.1 dev eth2 src 10.0.20.100
#ip route add default via GW
iproute delete - delete route
ip route del TYPE PRIFIX
示例:
#ip route delete 192.168.1.0/24
iproute show - list routes
TYPEPRIFIX
iproute flush - flush routing tables
TYPE PRIFIX
iproute get - get a single route
ip route get TYPE PRIFIX
示例:iproute get 192.168.0.0/24
ss命令:
ss [options] [ FILTER ]
選項:
-t:TCP協議的相關連接
-u:UDP相關的連接
-w:raw socket相關的連接
-l:監聽狀態的連接
-a:所有狀態的連接
-n:數字格式
-p:相關的程序及其PID
-e:擴展格式信息
-m:內存用量
-o:計時器信息
FILTER:= [ state TCP-STATE ] [ EXPRESSION ]
TCP的常見狀態:
TCPFSM:
LISTEN:監聽
ESTABLISEHD:建立的連接
FIN_WAIT_1:
FIN_WAIT_2:
SYN_SENT:
SYN_RECV:
CLOSED:
EXPRESSION:
dport=
sport=
示例:'( dport =:22 or sport = :22)'
~]#ss -tan '( dport = :22 or sport = :22 )'
~]#ss -tan state ESTABLISHED
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。