Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add simple static route support #496

Closed
zabbal opened this issue Apr 23, 2015 · 15 comments
Closed

add simple static route support #496

zabbal opened this issue Apr 23, 2015 · 15 comments

Comments

@zabbal
Copy link

zabbal commented Apr 23, 2015

In addition to existing lxc.network.ipv4 and lxc.network.ipv4.gateway would be great to be able to specify static routes inside the container config:
lxc.network.ipv4.route = 192.168.1.4/10.2.3.9
which would add inside the container:
ip route add 192.168.1.4 via 10.2.3.9

Instead of / we could use word via or whatever syntax is more convenient to parse.

@blakedot
Copy link

Yes, it would be great if the value of this AVP could just be passed to the "ip route" command.

For IPv6 too :-)

Thanks very much.

@ghost
Copy link

ghost commented Jun 27, 2016

+1
and yes - this would be awesome...

@stgraber
Copy link
Member

you do realize that most Linux distributions will flush any route that's present at container boot time right?

@ghost
Copy link

ghost commented Jun 27, 2016

Shouldn't it then flush 'away' the default gw as well - set via 'lxc.network.ipv4.gateway'?
[that's why I too think that it may be possible]

@stgraber
Copy link
Member

Yeah, it would. If your distro doesn't flush a pre-configured IP or default gateway, then this feature would work.

@ar45
Copy link
Contributor

ar45 commented Jun 28, 2016

Which distros do flush away lxc.network.ipv4.gateway?

@stgraber
Copy link
Member

ifupdown on Debian/Ubuntu used to either flush the routing table at boot or just completely fail when then attempting to add routing entries which are already present (causing boot to hang).

@ar45
Copy link
Contributor

ar45 commented Jun 28, 2016

I wonder. I am using that with debian jessie host and jessie containers and it works for me well. Is there any specific setup that is causing it?

@stgraber
Copy link
Member

Could be that ifupdown isn't flushing routes anymore (pretty sure NetworkManager still does), so the only problem you'd run into is if you had a conflicting route being applied with ifupdown.

@brauner
Copy link
Member

brauner commented Feb 6, 2018

That's not a feature we're likely to introduce for the aforementioned reasons by @stgraber.

@brauner brauner closed this as completed Feb 6, 2018
@apardyl
Copy link

apardyl commented Jan 2, 2019

I'm quite sure that the at least in case of debian, ubuntu, fedora and archlinux (installed with the download template) the guest os does not override network settings unless it receives a valid DHCP response.

A setting like lxc.net.[n].ipv[4/6].route = address/mask via gateway would be extremely useful in environments, where manual static configuration is required - it would enable users to set the entire networking configuration in the container config (as currently possible when only specifying the default gateway is sufficient).

Also @stgraber I thought that the entire point of lxc.net.[n].ipv[4/6].* options is to have all network config done by lxc, without touching it from the inside of the container (a very useful feature when creating containers from a template) - if you use ifupdown/NetworkManager/other you do not set lxc.net.[n].ipv[4/6].address and lxc.net.[n].ipv[4/6].gateway either because as you mentioned it would get flushed.

Sorry for commenting on such an old thread, but I was just going to ask you whether it would be possible to implement this when I found this issue, so I decided to comment here instead of opening a new one.

@kawogi
Copy link

kawogi commented Nov 11, 2019

Assuming this will not get implemented: what's the recommended way to add static routes to interfaces that are otherwise completely declared in the container's config?
I'm either used to configure them entirely within the container or externally. I haven't found mixed examples so far (Debian in my case).

@apardyl
Copy link

apardyl commented Nov 11, 2019

@fyl2xp1 currently I'm doing it like this:

# setup static routing
lxc.hook.mount = /etc/lxc/setup_routing.sh

where /etc/lxc/setup_routing.sh (file on lxc host) is:

ip ro add 10.30.0.0/16 via 10.20.0.1
ip ro add 10.10.0.0/16 via 10.20.0.1

It's a bit hacky, but it works.

@kawogi
Copy link

kawogi commented Nov 14, 2019

Thanks, I added to my /etc/network/interfaces:

auto eth3
iface eth3 inet manual
    post-up route add -net ...
    pre-down route del -net ...

This seems to work reliably but still feels odd because all other adapters as missing from that list and the rest of the interface's configuration resides in an external configuration.

@dominikdev-m
Copy link

Anything new on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

8 participants