IPRoute2

IPRoute2

Tips

Legacy utilityObsoleted byNote
ifconfigip addr, ip link, ip -sAddress and link configuration
routeip routeRouting tables
arpip neighNeighbors
iptunnelip tunnelTunnels
nameififrename, ip link set nameRename network interfaces
ipmaddrip maddrMulticast
netstatip -s, ss, ip routeShow various networking statistics

Notes

# 添加桥接
ip li add name br0 type bridge
# 添加 if
ip li set dev eth0 master br0
# 移除 if
ip li set dev eth0 nomaster
# 同时给 br0 添加多个地址可在保证网络访问的同事进行桥接
# 因为桥接, 所以 gw 的信息要手动配置
# 默认网关
ip route add 0.0.0.0/0 via 10.0.2.2
# 删除最上层的默认网关
ip ro del default
ip li set dev eth0 mtu 9000
ip route flush table main
ip route flush 172.17.0.0/16
ip route flush cache
ip -s route show cache
# greptap
# ==============================
# GRE bridging, IPsec and NFQUEUE http://backreference.org/2013/07/23/gre-bridging-ipsec-and-nfqueue/
# Layer 2 over Layer 3
#
# A
ip link add gretap0 type gretap local 172.31.0.1 remote 172.31.0.2
ip link set dev gretap0 up
ip link set dev eth0 up
brctl addbr br0
brctl addif br0 gretap0
brctl addif br0 eth0
ip addr add 10.10.10.1/24 dev br0
ip link set br0 up
# B
ip link add gretap0 type gretap local 172.31.0.2 remote 172.31.0.1
ip link set dev gretap0 up
ip link set dev eth0 up
brctl addbr br0
brctl addif br0 gretap0
brctl addif br0 eth0
ip addr add 10.10.10.2/24 dev br0
ip link set br0 up

FAQ

Stateless NAT with iproute2