Bridging a network interface

I’ve been trying out recently KVM. It supports NAT by default but you need to manually configure one of the physical interfaces of the system as bridge in order to enable you to bridge a virtual machine’s network.
At fist place I had to create a new interface configuration file for the bridge in /etc/sysconfig/network-scripts/ifcfg-br0

DEVICE=br0
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=yes

Once having the bridge file configured, I had to adjust the eth0 configuration:

DEVICE=eth0
HWADDR=00:22:29:18:A8:73
ONBOOT=yes
BRIDGE=br0

If instead of DHCP you’re using a static IP, then copy and paste the network information of ifcfg-eth0 to ifcfg-br

Checking after a reboot:

$ /sbin/ifconfig br0; /sbin/ifconfig eth0
br0       Link encap:Ethernet  HWaddr 00:22:29:18:A8:73
          inet addr:192.168.1.11  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::222:12ff:fe08:d113/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:449219 errors:0 dropped:0 overruns:0 frame:0
          TX packets:253636 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:593165878 (565.6 MiB)  TX bytes:133241643 (127.0 MiB)

eth0      Link encap:Ethernet  HWaddr 00:22:29:18:A8:73
          inet6 addr: fe80::222:12ff:fe08:d113/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:448789 errors:0 dropped:0 overruns:0 frame:0
          TX packets:313443 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:600638671 (572.8 MiB)  TX bytes:138369880 (131.9 MiB)
          Interrupt:177

In some cases I faced routing issues, the following solved them:

route add -net 192.168.1.0 gw 192.168.1.254 netmask 255.255.255.0 dev br0

One thought on “Bridging a network interface

  1. Pingback: Pages tagged "false"

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s