]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:ae:e4:d8 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:ae:e4:e2 brd ff:ff:ff:ff:ff:ff
]# ip link set eth1 down
]# ip link show eth1
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
link/ether 00:0c:29:ae:e4:e2 brd ff:ff:ff:ff:ff:ff
]# ip link set eth1 multicast off ]# ip link show eth1 3: eth1: <BROADCAST> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000 link/ether 00:0c:29:ae:e4:e2 brd ff:ff:ff:ff:ff:ff
]# ip link set eth1 name exxx
]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:ae:e4:d8 brd ff:ff:ff:ff:ff:ff
3: exxx: <BROADCAST> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
link/ether 00:0c:29:ae:e4:e2 brd ff:ff:ff:ff:ff:ff
]# ip link set eth1 mtu 2000
]# ip link show eth1
3: eth1: <BROADCAST> mtu 2000 qdisc pfifo_fast state DOWN qlen 1000
link/ether 00:0c:29:ae:e4:e2 brd ff:ff:ff:ff:ff:ff
]# ip netns list
]# ip netns add netspace
]# ip netns list
netspace
]# ip addr add 192.168.1.10/24 dev eno16777736
]# ip addr show eno16777736
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:60:1e:7a brd ff:ff:ff:ff:ff:ff
inet 10.0.1.20/24 brd 10.0.1.255 scope global eno16777736
valid_lft forever preferred_lft forever
inet 192.168.1.10/24 scope global eno16777736
valid_lft forever preferred_lft forever
]# ip addr add 192.168.2.10/24 dev eno16777736 label eno16777736:0
]# ip addr show eno16777736
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:60:1e:7a brd ff:ff:ff:ff:ff:ff
inet 10.0.1.20/24 brd 10.0.1.255 scope global eno16777736
valid_lft forever preferred_lft forever
inet 192.168.1.10/24 scope global eno16777736
valid_lft forever preferred_lft forever
inet 192.168.2.10/24 scope global eno16777736:0
valid_lft forever preferred_lft forever
]# ip addr del 192.168.2.10/24 dev eno16777736
]# ip addr del 192.168.1.10/24 dev eno16777736
]# ip ad sh eno16777736
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:60:1e:7a brd ff:ff:ff:ff:ff:ff
inet 10.0.1.20/24 brd 10.0.1.255 scope global eno16777736
valid_lft forever preferred_lft forever
]# ip addr show eno16777736
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:60:1e:7a brd ff:ff:ff:ff:ff:ff
inet 10.0.1.20/24 brd 10.0.1.255 scope global eno16777736
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe60:1e7a/64 scope link
valid_lft forever preferred_lft forever
]# ip addr add 10.10.10.10/8 dev eth1 label eth1:0
]# ip addr add 172.16.1.100/16 dev eth1 label eth1:1
]# ip addr show eth1
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:ae:e4:e2 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.100/24 brd 192.168.1.255 scope global eth1
inet 10.10.10.10/8 scope global eth1:0
inet 172.16.1.100/16 scope global eth1:1
]# ip addr flush dev eth1 ]# ip addr show eth1 3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:ae:e4:e2 brd ff:ff:ff:ff:ff:ff
]# ip route add 172.16.0.0/16 via 10.0.1.2 dev eth0 src 10.0.1.6
]# ip route show
10.0.1.0/24 dev eth0 proto kernel scope link src 10.0.1.6
192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.10
172.16.0.0/16 via 10.0.1.2 dev eth0 src 10.0.1.6
default via 10.0.1.2 dev eth0
]# ip route add default via 10.0.1.2 dev eth0
]# ip route show
10.0.1.0/24 dev eth0 proto kernel scope link src 10.0.1.6
192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.10
172.16.0.0/16 via 10.0.1.2 dev eth0 src 10.0.1.6
default via 10.0.1.2 dev eth0
]# ip route del 172.16.0.0/16
]# ip route del default
]# ip route show
10.0.1.0/24 dev eth0 proto kernel scope link src 10.0.1.6
192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.10
]# ip route get 192.168.1.0/24
broadcast 192.168.1.0 dev eth1 src 192.168.1.10
cache <local,brd> mtu 1500 advmss 1460 hoplimit 64
原创文章,作者:N24_ViCi,如若转载,请注明出处:http://www.178linux.com/62526
评论列表(1条)
博客完成的非常好,有图有真相,有实验结果。加油!