[Lxc-users] Set default GW
Bodhi Zazen
bodhi.zazen at montanalinux.org
Wed Jun 9 21:27:43 UTC 2010
I agree, the variability and flexibility of LXC is high.
I would imagine many uses involve networking (I would guess most people are most interested in isolating network aware applications) , so a simple config option
lxc.network.ipv4.gw 192.168.1.1
to set the default gw for the container or application. Sure you could add ipv6 too, but my guess is that ipv6 is not as popular as ipv4).
or similar would be of some use to most people. Such an option would not preclude your use, simple leave that line off and continue to use your init scripts.
Although I am new to LXC, I find it is easier to manage as much as possible in lxc.config files and a little as possible in the init scripts or containers.
For example,
lxc.network.ipv4 = 192.168.0.100/24
is, IMO, much easier then tracking down the network config files and setting a static ip within the container. Not a big deal mind you, but easier to review / edit a single config file.
I guess add this to the "wish list" (setting a default gw in the config file)
lxc.network.route
to set a route would be even better =)
----- Original Message -----
From: "Gordon Henderson" <gordon at drogon.net>
To: lxc-users at lists.sourceforge.net
Sent: Wednesday, June 9, 2010 2:55:28 PM
Subject: Re: [Lxc-users] Set default GW
On Wed, 9 Jun 2010, Bodhi Zazen wrote:
> Daniel - Thank you for answering, not a big deal.
>
> Gordon - Aye, that is what I do for containers. For applications I
> write an "init" script
>
> #!/bin/bash
>
> route add default gw 192.168.0.1 eth0
>
> Additional commands / config
>
> service start foo
> or what not (depending on the application).
>
> then
>
> lxc-execute -n foo -f foo.config /path_to/init_script
Actually, I sort of mis-read your mail and later realised you already
were using an init script.
In my init scripts, I often do a bit more - and often the default route
isn't on the same network that container's IP address is (same physical
LAN, different subnet) - a (real, live!) example:
In the config file, I have:
lxc.network.ipv4 = 195.10.226.165/27
and in the init script, (/etc/init.d/rcS) I have:
route add -net 195.10.225.64 netmask 255.255.255.224 dev eth0
route add -net 195.10.230.96 netmask 255.255.255.240 dev eth0
# route add -net 195.10.226.160 netmask 255.255.255.224 dev eth0
route add default gw 195.10.225.67
ifconfig eth0:53 195.10.226.164 netmask 255.255.255.224
ifconfig eth0:25 195.10.230.105 netmask 255.255.255.240
sh /etc/network/firewall
So how generic or otherwise should the config file be? I'd hate to see
it hard-wired into something that doesn't allow me that sort of
flexability... Although for starting simple applications (which I've no
use for), I can see it might be handy.
Gordon
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________ Lxc-users mailing list
Lxc-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users
More information about the lxc-users
mailing list