# Multiple interfaces Networking with DHCP

**URL:** <https://forums.suse.com/t/multiple-interfaces-networking-with-dhcp/5428>\
**Category:** RancherOS\
**Created:** [February 6, 2017, 1:43pm UTC](https://forums.suse.com/t/multiple-interfaces-networking-with-dhcp/5428 "2017-02-06T13:43:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaxL](https://avatars.discourse-cdn.com/v4/letter/m/b3f665/32.png) [@MaxL](https://forums.suse.com/u/MaxL)\
**Post date:** [February 6, 2017, 1:43pm UTC](https://forums.suse.com/t/multiple-interfaces-networking-with-dhcp/5428/1 "2017-02-06T13:43:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![MaxL](https://avatars.discourse-cdn.com/v4/letter/m/b3f665/32.png) [@MaxL](https://forums.suse.com/u/MaxL)\
**Post date:** [February 7, 2017, 4:59pm UTC](https://forums.suse.com/t/multiple-interfaces-networking-with-dhcp/5428/2 "2017-02-07T16:59:42Z")

</div>

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
