重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
常用的网络管理类工具有哪些,并用示例形式描述他们的使用方法。
京口ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联建站的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18982081108(备注:SSL证书合作)期待与您的合作!
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
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