There are many utilities from the bridge Network like bridge-util , iproute2 ,netplen, nmcil and ebtables, etc.
Here we use iproute2: Man page of IP command
The Frist OBJECT link is used for devices at the Layer 2 (data link connectivity )levels.
The subcommand of the link Object are: show, set, add, and del. For example in the above image
ip -c -br link show: Show Layer 2 info about the devices the Layer 2 information of both interfaces lo and enp0s3 for the default bridge
To Group the devices zero is the default group so we can create a new group 1 to the vi group file name red.
we can modify the attributes sudo ip link set dev lo group red
sudo ip link set dev enp0s3 group red
sudo ip link show group red
sudo ip link set dev enp0s3 up or sudo ip link set dev enp0s3 down
sudo ip link del dev docker0 (Delet docker0 virtual bridge)
sudo ip link add dev mybridge type bridge (Add mybridge virtual bridge with name mybridge)
An example of the virtual bridge(mybridge) with peer virtual interfaces of Ethernet (veth1,veth_1, and veth2,veth_2) is also two namespaces with a default namespace.
A namespace is a set of names that are used to identify and refer to objects of various kinds
for example mnt or mount, process or pid, network or net, user, and cgroup, etc.
1. Create a Bridge
○ ip link add name mybridge type bridge
2. Display bridge
○ ip -c -br link show mybridge
3. Create Virtual Ethernet interface peers(image make to ethernet cables)
○ ip link add name vth1 type veth peer vth_1
○ ip link add name vth2 type veth peer vth_2
○ ip -c -br link show type veth
4. Create Name Spaces
• Show any namespace exsit or not
○ ip netns ls
• Create namespaces
○ ip netns add ns1
○ ip netns add ns2
○ ip netns ls
5. Attach one end of both interfaces with namespace(link plug one end in namespace switch)
• Set vth_1 and vth_2 interface devices in ns1 and ns2 respectively. Make Layer 2 connectivity.
○ ip link set dev vth_1 netns ns1
○ ip link set dev vth_2 netns ns2
• Display the name spaces interfaces
○ ip -n ns1 -c -br link show
○ ip -n ns2 -c -br link show
• Up the virtual interfaces name spaces switches
○ ip -n ns1 link set dev vth_1 up
○ Ip -n ns2 link set dev vth_2 up
6. Assigned ip address to the virtual interface of namespaces switches
○ ip -n ns1 address add 192.168.10.1/24 dev vth_1
○ ip -n ns2 address add 192.168.10.2/24 dev vth_2
○ ip -c -br link show type bridge
○ ip -n ns1 -c -br address show
○ ip -n ns2 -c -br address show
Now we going to configure the switch of default namespace
1. Plugs virtual interfaces to the default namespace switch
○ ip link set dev vth1 master br0
○ ip link set dev vth2 master br0
2. Up the Ports vth1 and vth2 also bridge mybridge
○ ip link set dev vth1 up
○ ip link set dev vth2 up
○ ip -c -br link show
○ ip link set dev mybridge up
○ ip -c -br link show
3. Ping name space ns1 to ns2 interface vth_2
○ ip netns exec ns1 ping 192.168.10.2
Note: Ping is successful from ns1 to the virtual interface


Comments
Post a Comment