Showing posts with label bridge. Show all posts
Showing posts with label bridge. Show all posts

Connecting Two Subnet inside VMs in Linux

Tags: February 2, 2014 2:51 PM
0 comments

This should be applicable to real world (physical devices) not just virtualized environment. The topology is simple:

                 +----------------------------+
                 |          The Host          |
                 |          --------          |
                 |           Router           |
                 +----------------------------+
                       |               |
                    +-----+         +-----+
        192.168.1.1 | br0 |         | br1 | 192.168.1.9
                    +-----+         +-----+
                       |               |
  Mask: 192.168.1.0/29 |               | Mask: 192.168.1.8/29
        +--------------+               +----------+
        |              |                          |
        |              |                          |
 +--------------+      |                   +---------------+
 |     VM 1     |      +----+              |    VM 3       |
 | 192.168.1.2  |           |              | 192.168.1.10  |
 +--------------+           |              +---------------+
                    +--------------+
                    |     VM 2     |
                    | 192.168.1.3  |
                    +--------------+

The Details

The goal is to connecting VM in different subnet so they can talk to each other. Btw, I'm using Virtualbox for this playground. Here's the breakdown from the schema above:
  • The Host had two interface br0 and br1 (Both are virtual)
  • The schema using two subnet 192.168.1.0/29 and 192.168.1.8/29
  • The Host had two bridge interfaces and three TAP interfaces (for each VMs)
  • tap0 for VM 1, tap1 for VM 2 and tap2 for VM 3
  • tap0 and tap1 attached to br0 and tap2 attached to br1

Share on Facebook Twitter

How to Create Bridge Networking in Linux

Tags: February 1, 2014 1:47 PM
0 comments

Two user space tools used for creating bridge networking in linux are tunctl and brctl. tunctl used for simulating the network or link layer device and brctl for configuring them.

Create the TAP interface

Issue command below to create tap interface and then activate the tap.
tunctl -t vtap01 -u myuser
ip link set up dev vtap01
# or
ifconfig vtap01 up

Create the Bridge

Issue command below to configure the bridge for using the TAP interface which just created.
brctl addbr vbr01
brctl addif vbr01 vtap01

Assign IP and Routing to the Bridge

Make the bridge identified by others such as another computers or VMs (Assuming the network is 192.168.1.0/30).
ip link set up dev vbr01
ip addr add 192.168.1.1/30 dev vbr01
ip route add 192.168.1.0/30 dev vbr01
or it could be written as:
ifconfig vbr01 up
ifconfig vbr01 192.168.1.1 netmask 255.255.255.252
route add -net 192.168.1.0 netmask 255.255.255.252 dev vbr01
The host at 192.168.1.2 should be able to ping host 192.168.1.1 (via bridge).

References

Share on Facebook Twitter