路由
项目 | iproute2 | net-tools |
---|
查看套接字统计信息 | ss | netstat |
查看套接字统计信息(show listening only) | ss -l | netstat -l |
监视网络接口 | ip monitor | <NA> |
查看网络接口统计信息 | ip -s link | ifconfig -s |
查看所有已连接的网络接口 | ip link show | ifconfig -a |
启用网络接口 | ip link set eth1 up | ifconfig eth1 up |
停用网络接口 | ip link set eth1 down | ifconfig eth1 down |
改变网络接口的MAC地址 | ip link set dev eth1 address 08:00:27:75:2a:67 | ifconfig eth1 hw ether 08:00:27:75:2a:66 |
查看网络接口的IPv4地址 | ip addr show dev eth1 | ifconfig eth1 |
添加网络接口的IPv4地址 | ip addr add 10.0.0.1/24 dev eth1 | ifconfig eth1 10.0.0.1/24 |
删除网络接口的IPv4地址 | ip addr del 10.0.0.1/24 dev eth1 | ifconfig eth1 0 |
删除网络接口的所有IPv4地址 | ip addr flush dev eth1 | <NA> |
查看网络接口的IPv6地址 | ip -6 addr show dev eth1 | ifconfig eth1 |
添加网络接口的IPv6地址 | ip -6 addr add 2002:0db5:0:f102::1/64 dev eth1 | ifconfig eth1 inet6 add 2002:0db5:0:f102::1/64 |
删除网络接口的IPv6地址 | ip -6 addr del 2002:0db5:0:f102::1/64 dev eth1 | ifconfig eth1 inet6 del 2002:0db5:0:f102::1/64 |
查看IPv4路由表 | ip route show | route -n |
查看IPv4路由表 | ip route show | netstat -rn |
添加IPv4默认路由 | ip route add default via 192.168.1.2 dev eth0 | route add default gw 192.168.1.2 eth0 |
删除IPv4默认路由 | ip route del default via 192.168.1.1 dev eth0 | route del default gw 192.168.1.1 eth0 |
修改IPv4默认路由 | ip route replace default via 192.168.1.2 dev eth0 | <NA> |
添加IPv4静态路由 | ip route add 172.16.32.0/24 via 192.168.1.1 dev eth0 | route add -net 172.16.32.0/24 gw 192.168.1.1 dev eth0 |
删除IPv4静态路由 | ip route del 172.16.32.0/24 | route del -net 172.16.32.0/24 |
删除IPv4所有路由 | ip route flush dev eth0 | <NA> |
查看IPv4路由出口 | ip -s route get 192.168.1.1 | <NA> |
查看ARP表 | ip neigh | arp -an |
添加静态ARP项 | ip neigh add 192.168.1.100 lladdr 00:0c:29:c0:5a:ef dev eth0 | arp -s 192.168.1.100 00:0c:29:c0:5a:ef |
删除静态ARP项 | ip neigh del 192.168.1.100 dev eth0 | arp -d 192.168.1.100 |
查看多播地址 | ip maddr list dev eth0 | ipmaddr show dev eth0 |
添加多播地址 | ip maddr add 33:44:00:00:00:01 dev eth0 | ipmaddr add 33:44:00:00:00:01 dev eth0 |
删除多播地址 | ip maddr del 33:44:00:00:00:01 dev eth0 | ipmaddr del 33:44:00:00:00:01 dev eth0 |
ref:
iproute2 对决 net-tools
策略路由
项目 | iproute2 |
---|
查看IPv4策略路由规则 | ip rule show |
添加IPv4策略路由规则 | ip rule add from 192.168.0.0/24 to 192.168.1.0/24 iif eth0 oif eth1 fwmak 0x1234 table 1 pref 100 |
删除IPv4策略路由规则 | ip rule del from 192.168.0.0/24 to 192.168.1.0/24 iif eth0 oif eth1 fwmak 0x1234 table 1 pref 100 |
查看IPv4策略路由的路由表 | ip route show table 1 |
添加IPv4策略路由的默认路由 | ip route add table 1 default via 192.168.1.2 dev eth0 |
删除IPv4策略路由的默认路由 | ip route del table 1 default via 192.168.1.1 dev eth0 |
修改IPv4策略路由的默认路由 | ip route replace table 1 default via 192.168.1.2 dev eth0 |
添加IPv4策略路由静态路由 | ip route add table 1 172.16.32.0/24 via 192.168.1.1 dev eth0 |
删除IPv4策略路由静态路由 | ip route del table 1 172.16.32.0/24 |
桥
项目 | 语法 | 例子 |
---|
add bridge | brctl addbr <bridge> | |
delete bridge | brctl delbr <bridge> | |
add interface to bridge | brctl addif <bridge> <device> | |
delete interface from bridge | brctl delif <bridge> <device> | |
turn hairpin on/off | brctl hairpin <bridge> <port> {on|off} | |
set ageing time | brctl setageing <bridge> <time> | |
set bridge priority | brctl setbridgeprio<bridge> <prio> | |
set bridge forward delay | brctl setfd <bridge> <time> | |
set hello time | brctl sethello <bridge> <time> | |
set max message age | brctl setmaxage <bridge> <time> | |
set path cost | brctl setpathcost <bridge> <port> <cost> | |
set port priority | brctl setportprio <bridge> <port> <prio> | |
show a list of bridges | brctl show [ <bridge> ] | |
show a list of mac addrs | brctl showmacs <bridge> | |
show bridge stp info | brctl showstp <bridge> | |
turn stp on/off | brctl stp <bridge> {on|off} | |
vlan
项目 | 描述 |
---|
加载vlan模块 | modporbe 8021q |
项目 | iproute2 | net-tools |
---|
添加vlan网络接口 | ip link add link eth0 name eth0.5 type vlan id 5 | vconfig add eth0 5 |
删除vlan网络接口 | ip link delete eth0.5 | vconfig rem eth0.5 |
注意:
一个的物理网络接口,只有一个的vlan id。可以看作为 access 口。
一个的物理网络接口,如果有多于一个的vlan id。可以看作为 trunk 口。