# 查看端口使用情况 netstat -ntulp | grep port-num -t (tcp) 仅显示tcp相关选项 -u (udp)仅显示udp相关选项 -n 拒绝显示别名,能显示数字的全部转化为数字 -l 仅列出在Listen(监听)的服务状态 -p 显示建立相关链接的程序名 # 除了基本用法以外,还可以查看以下内容 --route , -r Display the kernel routing tables. See the description in route(8) for details. netstat -r and route -e produce the same output. --groups , -g Display multicast group membership information for IPv4 and IPv6. --interfaces, -i Display a table of all network interfaces. --masquerade , -M Display a list of masqueraded connections. --statistics , -s Display summary statistics for each protocol.
/proc -- Mount point for the proc filesystem, which gives access to kernel status information via the following files. /proc/net/dev -- device information /proc/net/raw -- raw socket information /proc/net/tcp -- TCP socket information /proc/net/udp -- UDP socket information /proc/net/igmp -- IGMP multicast information /proc/net/unix -- Unix domain socket information /proc/net/ipx -- IPX socket information /proc/net/ax25 -- AX25 socket information /proc/net/appletalk -- DDP (appletalk) socket information /proc/net/nr -- NET/ROM socket information /proc/net/route -- IP routing information /proc/net/ax25_route -- AX25 routing information /proc/net/ipx_route -- IPX routing information /proc/net/nr_nodes -- NET/ROM nodelist /proc/net/nr_neigh -- NET/ROM neighbours /proc/net/ip_masquerade -- masqueraded connections /proc/net/snmp -- statistics
route
show / manipulate the IP routing table
usage
1 2 3 4 5 6
route add : delete a route del : add a new route -n : show numerical addresses # 其实应该就是读取了文件/proc/net/route -- IP routing information # netstat --route|-r 也可以返回一样的结果,不过netstat应该只能查看不能删改
example
1 2 3 4 5 6 7
sparta@vostrozhc:~$ route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default shz82b-ldr01-v5 0.0.0.0 UG 100 0 0 enp2s0 10.67.104.0 * 255.255.255.0 U 100 0 0 enp2s0 shzsdns401.ccr. shz82b-ldr01-v5 255.255.255.255 UGH 100 0 0 enp2s0 link-local * 255.255.0.0 U 1000 0 0 enp2s0