Host only:
The mubr0 configuration address is both the switch of the va/vb/host machine and the virtual network card of the host machine. This address is in the same network segment as va/vb and is a host-
only simulation host:
yum install bridge-utils-1.5-9.el7. x86_64
[root@node2~]#rpm -ql bridge-utils
brctl -h
[root@node2~]#brctl show
[root@node2~]#brctl addbr mubr0 (Switch
[root@node2~]#brctl show
[root@node2~]#ip link set mubr0 up
[root@node2~]#ifconfig -a
virtual Ethernet card:
create a pair Virtual network card:
[root@node2~]#ip link help
[root@node2~]#ip link add veth0.1 type veth peer name veth0.2
ifconfig -a
[root@node2~]#brctl help
[root@node2~]#brctl addif mubr0 veth0.2
[root@node2~]#brctl show
bridge name bridge id STP enabled interfaces
mubr0 8000.5adb0e8e541a no veth
Create a second pair of virtual network cards:
[root@node2~]#ip link add veth1.1 type veth peer name veth1.2
ip link delete veth0.1
[root@node2~]#brctl addif mubr0 veth1.2
[root@node2~]#brctl show
Create a namespace:
[root@node2~]#ip netns add v0
[root@node2~]#ip netns add v1
[root@node2~]#ip netns list
v1
v0
[root@node2~]#ip netns delete v2
[root@node2~]#ip link set veth0.1 netns v0 "A namespace is similar to a virtual machine"
[root@node2~]#ip link set veth1.1 netns v1
[root@node2~]#ifconfig -a
[root@node2~]#ip netns exec v1 ifconfig -a
[root@node2~]#ip netns exec v0 ifconfig -a
[root@node2~]#ip netns exec v0 ifconfig veth0.1 10.1.0.1/24 up
[root@node2~]#ip netns exec v1 ifconfig veth1.1 10.1.0.2/24 up
[root@node2~]#ip link set veth1.2 up
[root@node2~]#ip link set veth0.2 up
ip netns exec v0 ping 10.1.0.2
[root@node2~]#ifconfig mubr0 10.1.0.254/24
[root@node2~]#ip netns exec v0 ping 10.1.0.254