Skip to main content

Linux as a software Switch / Router Bridge


Network Interfaces
Creating two network interfaces in Linux
sudo ip link add eth0dummy1 type dummy
sudo ip link add eth0dummy2 type dummy
Setting those interfaces up
sudo ip link set up eth0dummy1
sudo ip link set up eth0dummy2
Showing existing interfaces
ip addr list
MAC is assigned to eth0dummy1 and eth0dummy2 interfaces

Bridge
Creating the bridge
sudo brctl addbr dummybridge
Setting the bridge up
sudo ip link set up dummybridge 
Adding interfaces to the bridge
sudo brctl addif dummybridge eth0dummy1 eth0dummy2
Showing existing bridges
sudo brctl show
Showing virtual ports and MAC addresses
sudo brctl showmacs dummybridge
virtual port 1 attached to eth0dummy1 interface MAC and port 2 to eth0dummy2 MAC


Router
Converting the bridge to a router by assigning a L3 address.
sudo ip addr add 172.16.0.1/24 dev dummybridge

Reference

Comments

Popular posts from this blog

Hub vs Bridge vs Switch

Hub Layer: Physical Layer Connects network segments (wires) and broadcast traffic (without knowing to know MAC).  Bridge Layer - Data Link Layer Connects two network segments (wires) and forward packets based on the MAC.  Can be a software or a hardware.  Switch Layer - Data Link Layer Multiple bridges are implemented in a switch hence it can forward traffic between more than two network segments based on the MAC. 

Running a docker container in host network namespace

Docker is utilizing network namespaces of Linux to provide the isolation for the containers. However, it is possible to define in which network namespace the container should be running. Hence, we can also get a container running in the host network. docker run --name hostbusybox --network=host busybox Since the above container is running in the host network, the interface of the container can be seen with the following command ip addr list

Linux default route in routing table in VB with NAT

The routing table has the following entries by default with Virtual Box is used with NAT.  Destination  Gateway  Meaning  0.0.0.0       10.0.2.2  The traffic to any undefined network/IP address will be forwarded to the default gateway at 10.0.2.2     10.0.2.0       0.0.0.0  The traffic to the network 10.0.2.0/24 does not need any special gateway. The traffic can be directly forwarded.    169.254.0.0  0.0.0.0  The Link-Local address . If a DHCP server is not available, the server broadcast the it's own IP assignment using the link local address. See ARP.    172.17.0.0  0.0.0.0 The docker bridge since this machine has docker installed.