[libvirt-users] assign static external IP to container

Gao feng gaofeng at cn.fujitsu.com
Mon Dec 16 02:47:28 UTC 2013


On 12/14/2013 10:51 AM, scar wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> Gao feng @ 12/12/2013 10:18 PM:
>> I saw there are two bridge br0 and virbr0 in your host. which
>> bridge the libvirt uses?  what's result of #virsh net-list ?
> 
> well i don't quite understand bridges and their function, i'm kinda
> just following directions.  br0 replaced eth0 though in my interfaces
> file according to this guide[1] i followed to setup the bridge.  i'm
> pretty sure virbr0 is what libvirt uses....
> 
> host$ cat /etc/network/interfaces
> auto lo
> iface lo inet loopback
> 
> auto br0
> iface br0 inet static
> 	address 67.180.246.122
> 	netmask 255.255.255.248
> 	gateway 67.180.246.121
> 	dns-nameservers 67.180.241.11 67.180.241.12
> 	bridge_ports eth0
> 	bridge_fd 9
> 	bridge_maxage 12
> 	bridge_stp off
> 

remove this br0 sector from the interfaces file. and restart the network. (remove the bridge br0)
I'm not familiar with the configure files in ubuntu,
let's use the command.

1, ifconfig eth0 0.0.0.0
2, brctl addif virbr0 eth0
3, ifconfig virbr0 67.180.246.122/29
4,ip route add default via 67.180.246.121 dev virbr0
5, ifconfig eth0 x.x.x.x/29 (in container)
6, ip route add default via 67.180.246.121 dev eth0 (in container)

but this will not work when you restart libvirt.

> host$ virsh net-list
> Name                 State      Autostart
> - -----------------------------------------
> default              active     yes
> 
> host$ virsh net-dumpxml default
> <network>
>   <name>default</name>
>   <uuid>e6d3f97a-5870-8ee7-1d82-64b3434f138b</uuid>
>   <forward mode='nat'/>
>   <bridge name='virbr0' stp='on' delay='0' />
>   <ip address='192.168.122.1' netmask='255.255.255.0'>
>     <dhcp>
>       <range start='192.168.122.2' end='192.168.122.254' />
>     </dhcp>
>   </ip>
> </network>
> 
> $
> 
> 
> 1.
> https://help.ubuntu.com/12.04/serverguide/network-configuration.html#bridging
> -----BEGIN PGP SIGNATURE-----
> 
> iEYEAREIAAYFAlKrx58ACgkQXhfCJNu98qDHhwCguJBus/7kZj+5R2EAYSzSENg8
> SFwAoLVCxi6jJQBaUhMl4Ter+Jnvq/rI
> =4wm8
> -----END PGP SIGNATURE-----
> 
> _______________________________________________
> libvirt-users mailing list
> libvirt-users at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-users
> 





More information about the libvirt-users mailing list