# Routing setup issue

## Cr0t

I have two networks, which I am using. One is 2x1gb bonded (bond0) and one wifi 802.11g network. Both networks HAVE to push out the IP over dhcp so static IPs are not possible.

The bonded link is the main link and the wifi link is only supposed to be used for one server and nothing else.

bond0 gw 192.168.0.1 subnet 255.255.255.240

wlan0 gw 192.168.1.1 subnet 255.255.255.224

Both links can use the same DNS server, but not the same gateway. In this example let's call that server wlan0serveronly.

with no wlan0 running:

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

0.0.0.0         192.168.0.1     0.0.0.0         UG    204    0        0 bond0

127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo

192.168.0.0     0.0.0.0         255.255.255.240 U     204    0        0 bond0

with wlan0 running:

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

0.0.0.0         192.168.0.1     0.0.0.0         UG    204    0        0 bond0

0.0.0.0         192.168.1.1     0.0.0.0         UG    308    0        0 wlan0

127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo

192.168.0.0     0.0.0.0         255.255.255.240 U     204    0        0 bond0

192.168.1.0     0.0.0.0         255.255.255.224 U     308    0        0 wlan0

I thought this would be straight forward, but I am not able to get this to work 100%.

I thought I would remove the default GW for wlan0 and the net for wlan0. Next I would just add the host target. Well didn't work.

=> remove the default GW via : route del default gw 192.168.1.1

=> remove net for wlan0 via : route del -net 192.168.1.0/27

netstat -r

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

0.0.0.0         192.168.0.1     0.0.0.0         UG    204    0        0 bond0

127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo

192.168.0.0     0.0.0.0         255.255.255.240 U     204    0        0 bond0

=> looks like we are back to the original config without wlan0

let's try to add wlan0serveronly

route add -host wlan0serveronly gw 192.168.1.1 wlan0

=> doesn't go out over wlan0

if I skip the two remove lines and just run the add the outgoing ping works, however not incoming... need some help  :Smile: 

----------

## Mad Merlin

In general, you cannot have two DHCP leases concurrently on one machine (even if the interfaces are different), the reason is that the DHCP client will set your default route and you cannot have more than one default route.

It looks like you're pretty close already. However, is wlan0serveronly in 192.168.1.0/27? If not, you need to keep that net rule, otherwise, wlan0 cannot possibly reach it.

----------

## Cr0t

That is what I have read that you need to have the basic net rule otherwise you can't go out. If I leave it and just use the add host line it goes out of wlan0, but the return traffic comes over bond0. Does not really make any sense.

IF the routing doesn't work, I was thinking maybe I could use iptables. I would rather use a routing table.

----------

## Mad Merlin

What's the source IP in the requests you make to wlan0serveronly? If it's the IP on bond0, then it makes complete sense that the return traffic would go to bond0 and not wlan0.

----------

## Cr0t

... it goes out over wlan0, but I understand what you are saying. The preferred nic is bond0 and returns to that one. At this point I think I might have to use iptables.

----------

