Multiple interfaces Networking with DHCP

Hi guy’s,

I discovered recently rancherOS and i use it with an openstack cloud (last openstack image 0.7.1). My goal is to launch lightweight VMs with docker services… But I try since a couple of days to find a solution for working with 2 interfaces in DHCP mode with cloud-init. I don’t want to do post-up config and try to find a solution with cloud-init…

For my setup, i need to remove the default route on eth0 interface so i first try with an “ip route del default dev eth0” in post_up commands in networking config and it does not seem to work. However post_cmds seems to work for adding static routes (not playing with default one).

I try the “write_files” option with /opt/rancher/bin/ and i succeed doing a “ip route flush 0/0” but of course it removes the two default routes from eth0 and eth1… So after the flush i obviously try to just add the default route needed on eth1 like this :

" - path: /opt/rancher/bin/
permissions: “0755"
owner: root
content: |
# routes
ip route flush 0/0
ip route add default dev eth1”

My surprise that default route is added on both eth0 and eth1 :

" default via dev eth0 src metric 202
default via dev eth1 src metric 203 "

After this, which seems to me anormal, i dig toward dhcpcd client an try to find another solution. I found that there are some “dhcp_args” option in the networking config but I don’t catch how this is working since I try to add “–nogateway” option to dhcpcd CLI … could someone explain me how this should be used or if there is a bug because it seems trying to do an exec.

[rancher@ranchertest ~]$ sudo ros config set “’–nogateway’”
[rancher@ranchertest ~]$ sudo netconf --stop-network-pre
INFO[0000] Running network: stop-network-pre=true
INFO[0000] Running command route [add -net dev eth0]
INFO[0000] Running command route [del default dev eth0]
INFO[0000] Running DHCP on eth0
ERRO[0000] exec: “–nogateway”: executable file not found in $PATH
INFO[0000] Running DHCP on eth1
sending commands to master dhcpcd process

At the end my question is quite simple: is there a way to play with the default routes with cloud-init ??

Thanks for your help and the great work done …



Finally found this solution that is working :

dhcp: true
dhcp_args: dhcpcd -MA4 --nogateway
dhcp: true
dhcp_args: dhcpcd -MA4 --nogateway
- route add -net dev eth0
- route add default dev eth1

If it could help somebody else.


1 Like