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 rancher.network.interfaces.eth0 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/start.sh 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 :

write_files:
" - path: /opt/rancher/bin/start.sh
permissions: “0755"
owner: root
content: |
#!/bin/bash
# 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 100.64.0.1 dev eth0 src 100.64.0.5 metric 202
default via 10.0.0.1 dev eth1 src 10.0.0.251 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 rancher.network.interfaces.eth1.dhcp_args “’–nogateway’”
[rancher@ranchertest ~]$ sudo netconf --stop-network-pre
INFO[0000] Running network: stop-network-pre=true
INFO[0000] Running command route [add -net 10.0.0.0/8 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 …

Max

Hi,

Finally found this solution that is working :

rancher:
network:
interfaces:
eth0:
dhcp: true
dhcp_args: dhcpcd -MA4 --nogateway
eth1:
dhcp: true
dhcp_args: dhcpcd -MA4 --nogateway
dns:
nameservers:
- 8.8.8.8
- 8.8.4.4
post_cmds:
- route add -net 10.0.0.0/8 dev eth0
- route add default dev eth1

If it could help somebody else.

Max

1 Like