Creating a Linux bridge

A network bridge helps you connect 2 different networks with the same characteristics (Ethernet for example). Its very easy to implement it in linux using some tools

Example

We run Qemu  image with tap interface – we can connect from the qemu image to the linux host but we cant access the entire network (internet)

Qemu script:

sudo qemu-system-x86_64 -net tap -net nic  -kernel bzImage -m 1G -append “console=tty1 root=/dev/nfs nfsroot=192.168.0.1:/home/developer/x86system/outfs ip=192.168.0.2:192.168.0.1:192.168.0.1:255.255.255.0:qemu:eth0

here we define a virtual network card (tun mode). The network card connects qemu and linux for NFS file system and for communication so if we ping 192.168.0.1 from qemu we get response but if we ping other ip address from external network we don’t get any response

 

to solve this lets define a bridge to connect qemu to the internet:

first we add another network adapter to the qemu image:

 

While running the emulator Linux creates 2 adapters (tap0, tap1)

 

to connect to second adapter we need to set an ip address in qemu:

Now Qemu connected to linux host with 2 adapters , one for NFS and the second we want to configure with the bridge

 

Create a new bridge:

Set it up

Add the network interface and set it master

Add the tap interface to the bridge

Now if you ping the same address , it will work

 

Delete the bridge:

 

Tagged

Leave a Reply

Your email address will not be published. Required fields are marked *