[Lxc-users] Set default GW

Gordon Henderson gordon at drogon.net
Wed Jun 9 20:04:37 UTC 2010


On Wed, 9 Jun 2010, Bodhi Zazen wrote:

> Is there a way to set the default gateway in a linux container ?
>
> If I set an ipaddress in the config file
>
> lxc.utsname = foo
> lxc.network.type = veth
> lxc.network.flags = up
> lxc.network.link = br0
> lxc.network.name = eth0
> lxc.network.mtu = 1500
> lxc.network.ipv4 = 192.168.0.10/24
>
> These lines set the ip address of the guest.
>
> Now if I use it either as a container (adding a rootfs , fstab, devices and running lxc-start -n foo) or as an application (using the system / and lxc-execute -n foo -f /lxc/foo.config /bin/bash) , everything starts as expected, I can enter the container with lxc-console, etc ...
>
> The "problem" is the default gw is not set. I have to either add the gw manually (when running /bin/bash) or adding it to the init scripts (if running a container)
>
> route add default gw 192.168.0.1 eth0
>
> after running the route command everything works as expected.
>
> So, what I am asking, is there a way of setting the default route / gw 
> in the config file, foo.config ?

I'm doing it in /etc/init.d/rcS in my debian systems. Setting the default 
route, as well as other aliases for the network interface.

Gordon




More information about the lxc-users mailing list