iproute2, net-tools是网络相关命令的包。 前者是新一代工具包,可以替换net-tools。iproute2的效率会更高。
MSL:Maximum Segment Lifetime 最长报文寿命
-c: 持续每秒打印信息
-r: 打印内核路由表
-g: 打印ipv4,ipv6多播组成员信息
-i: 打印所有的网络网卡信息
-s: 打印每个协议的统计信息
-a: 打印所有的连接
-n: 直接使用IP地址
-t, -u: 显示TCP/UDP协议的连接情况
-l: 显示监听中的连接状况
-p: 打印连接所属的进程号
netstat => ss
netstat -r=> ip route => route -e
netstat -i=> ip -s link
netstat -g=> ip madder
用来打印socket统计数据
-m: socket的内存使用情况
ss -t -a : 显示所有TCP socket
ss -u -a : 显示所有UDP socket
用于显示或设置网络设备
-a: 展示所有网关信息
-s: 展示简短的列表 => netstat -i
Ifconfig interface up: 打开interface
ifconfig interface down: 关闭interface
ifconfig interface [-]arp: 关闭或打开arp
ifconfig interface netmask XXX: 修改子网掩码
显示或修改路由,网络设备,网卡等信息
可以替换ifconfig
link: 网络设备
route: 路由表
rule: 路由策略的规则
address: 设备上的协议地址
addrlabel: 协议地址选择的标签
ip 常用对象: 查看相关信息
ip link set interface up/down: 开启/关闭网卡
ip route add 192.168.4.0/24 via 192.168.0.254 dev eth0: 设置192.168.4.0网段的网关为192.168.0.254,数据走eth0接口
telnet, ping 分别可以用来判断程序是否正常运行和网络是否通畅
使用方式:
telnet www.baidu.com 80
ping www.baidu.com -c 5
ping使用ICMP(Internet Control Message Protocol)协议通信,有些服务器可能会关闭icmp的应答,导致无法ping通。
telnet 的关闭 用quit
打印从本机到目的地址的路径以及耗时
traceroute address显示或操作IP路由表
set the metric field in the routing table (used by routing daemons) to M. If this option is not specified the metric for inet6(IPv6) address family defaults to '1', for inet (IPv4) it defaults to '0'. You should always specify an explicit metric value to not rely on those defaults - they also differ from iproute2.
route add -net 127.0.0.0 netmask 255.0.0.0 metric 1024 dev lo
route del default
route del -net 192.56.76.0 netmask 255.255.255.0
ipv4 ipv6 以及NAT管理工具
默认表: raw mangle nat filter security
# 查看规则
iptables -L
# 指定表
iptables -t
# 添加规则
iptables -A
# 插入规则
iptables -I
# 删除规则
iptables -D
#允许本地地址可以使用 -j jump 指跳到该规则后要执行的动作
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
# 允许180.120.0.5访问本机12345端口 ACCEPT:通过 DROP:禁止 -p:协议 -s:源地址
iptables -A INPUT -p tcp -s 180.120.0.5 --dport 12345 -j ACCEPT
| 留言与评论(共有 0 条评论) “” |