LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Blogs > sfxpt
User Name
Password

Notices



Rate this Entry

Manually setup KVM public bridge

Posted 08-18-2010 at 10:36 AM by sfxpt
Updated 08-18-2010 at 12:17 PM by sfxpt

Setting up KVM public bridge manually is actually quite easy, following

http://tldp.org/HOWTO/BRIDGE-STP-HOW...he-bridge.html
and
http://www.linux-kvm.org/page/Networking#public_bridge

Code:
# My initial status
% ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:1f:16:a4:d0:8c  
          inet addr:192.168.0.108  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:16888 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12404 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:24617836 (23.4 MiB)  TX bytes:921398 (899.8 KiB)
          Interrupt:16 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:100 (100.0 B)  TX bytes:100 (100.0 B)

# Disable any dhcp clients if any!

# Setup tun tap0
% tunctl -t tap0 -g kvm
Set 'tap0' persistent and owned by gid 103

# Create the bridge interface.
% brctl addbr br0

# Add interfaces to the bridge.
% brctl addif br0 eth0
% brctl addif br0 tap0

# Zero IP the interfaces.
% ip addr flush eth0
% ifconfig eth0 0.0.0.0
% ifconfig tap0 0.0.0.0

# Put up the bridge.
% ifconfig br0 192.168.0.108 netmask 255.255.255.0 up
% route add default gw 192.168.0.1 metric 1

# This gives you a fixed IP, just replace the last 2 lines with your normal DHCP command if you want a dynamic IP.

# Status scheck
% ifconfig
br0       Link encap:Ethernet  HWaddr 00:1f:16:a4:d0:8c  
          inet addr:192.168.0.108  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eth0      Link encap:Ethernet  HWaddr 00:1f:16:a4:d0:8c  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:66 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:12636 (12.3 KiB)  TX bytes:0 (0.0 B)
          Interrupt:16 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:200 (200.0 B)  TX bytes:200 (200.0 B)

tap0      Link encap:Ethernet  HWaddr 8a:0d:1d:f2:79:a9  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.0.0     *               255.255.255.0   U     0      0        0 br0
default         192.168.0.1     0.0.0.0         UG    1      0        0 br0

$ ping 192.168.0.1
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=127 time=0.368 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=127 time=0.356 ms
64 bytes from 192.168.0.1: icmp_seq=3 ttl=127 time=0.328 ms
^C

# To start kvm:
kvm -m 1024 -smp 2 -net nic,macaddr=52:54:00:39:81:49 -net tap,ifname=tap0,script=no,downscript=no . . .
That's it.

The guests will run on the same subnet as host, having the same route and DNS server.
Posted in Uncategorized
Views 4087 Comments 1
« Prev     Main     Next »
Total Comments 1

Comments

  1. Old Comment
    Comments disabled, please follow up on
    http://www.linuxquestions.org/questi...299/page2.html
    Posted 08-18-2010 at 12:08 PM by sfxpt sfxpt is offline
 

  



All times are GMT -5. The time now is 06:08 AM.

Main Menu
Advertisement

Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration