Default route in quagga doesn't work if specified using interface rather than address

2

I have the following zebra.conf on my router box "A":

hostname nuclear-router
password password
enable password password

interface eth0
ip address 192.168.2.1/24
multicast
no shutdown

interface wlan0
ip address 192.168.1.2/24
multicast
no shutdown

#ip route 0.0.0.0/0 wlan0 # Does not work. 
ip route 0.0.0.0/0 192.168.1.1 # Works beautifully

eth0 is connected to a switch and contains the 192.168.2.0/24 range, and A is connected to my WRT54GL "B" (with IP 192.168.1.1, containing 192.168.1.0/24 range, DHCP serves IPs above .100) wirelessly. B is connected directly to my DSL modem.

The problem is that when I specify the default route using the interface name, I can't connect to the internet from A or any hosts behind it - I'm always hit with a "no route to host" error. Name lookup and pinging any local host (even in a different range) or the DSL modem works fine - it's only when going beyond the modem that things stop working. However, when I use the IP of B as the gateway, it works fine. I noticed that route output on A when the default route was specified using the interface alone had only an asterisk in the gateway column. I was under the impression that these approaches should be identical in practice, so though I got it working, I'd like to know what I'm misunderstanding (and/or misconfiguring). Why didn't the default route work when specified using just the interface?

All routers and the modem too have RIP (version 2) enabled, and of course the password isn't really the word "password".

jaymmer - Reinstate Monica

Posted 2013-04-05T03:11:01.600

Reputation: 131

Answers

2

While a default route might work in the desired manner when the destination is a point-to-point layer-2 link, it assuredly won't work to a broadcast interface like ethernet or wlan. Configurable routes are at OSI Layer 3 (IP numbers), and ought not to require MAC addresses (Layer 2), interface names (layer 1), or port numbers or packet types (layer 4+). Once the right destination IP number is provided for a route, the router will handle what MAC address to forward packets towards, and which interface that MAC is connected.

In summary, setting your default route to an interface name doesn't work because its not supposed to... If you don't know what IP address is supposed to handle forwarding of non-local traffic, then it's best not to have a default route set.

Nevin Williams

Posted 2013-04-05T03:11:01.600

Reputation: 3 725

Default routes on some devices can point to interfaces and not IP's. It's generally not recommended, but is technically possible. – cpt_fink – 2013-04-07T05:34:18.137

I completely forgot to consider that there are other machines receiving in the same subnet, now in this light it's all obvious (d'oh) – jaymmer - Reinstate Monica – 2013-04-07T07:26:10.300

Yeah, one can point default route to a serial interface or other point-to-point routes; I don't think it works very well on broadcast interfaces, however. – Nevin Williams – 2013-04-11T08:25:41.960

-1

Seems to me you are confusing the hostname with the interface name. The name wlan0 is the name of the interface. The hostname is stored in the DNS and is what the lookup returns.

Most likely, what is happening is DNS is looking up the host wlan0 and coming up with the error no host found.

Mei

Posted 2013-04-05T03:11:01.600

Reputation: 349

Who do you think this? It doesn't make any sense to me... why would the DNS be looking up "wlan0"? – jaymmer - Reinstate Monica – 2013-04-05T21:34:56.810

Consider: the the command ip route 0.0.0.0/0 wlan0 fails, but the command ip route 0.0.0.0/0 192.168.1.1 works. The only way to get from wlan0 to 192.168.1.1 is via the DNS system somewhere. – Mei – 2013-04-15T22:30:03.290

But why would the interface name be looked up through DNS? The zebra.conf manpage says that the ip route command takes either IP address or the interface name, not a domain name or anything that should ever touch the DNS. – jaymmer - Reinstate Monica – 2013-04-17T02:09:02.483

I was considering the ip(8) command - and I'm pretty sure that you would need the keyword dev before a device name. Also, being able to use a name or IP in the same slot is standard practice. Perhaps the configuration file is different - though if you can use a device name or IP, that sounds like it complicates the use of DNS host names. – Mei – 2013-04-17T19:35:53.003