I am currently trying to configure a router to which I connect to (to its web interface) using an Ethernet cable through the eth0 interface. That router doesn't have access to the internet.

Now, I have access to another network (different IP range and all) that does have access to the internet through my wireless interface wlan0.

I would like to use eth0 to only connect to the router I am trying to configure and wlan0 for the rest of the connections. That way, I could do some research while trying to configure the router.

I'm sure it's doable, with some kind of routing but I haven't been able to find anything that works. The issue is that when I plug the Ethernet cable, the system starts using that eth connection for everything.

To sum up a bit:

Assuming the router's address is, can I do something to route traffic going to through the eth0 interface and anything else through wlan0?

I am using Debian Squeeze.


There are a few possible options here.


Don't use DHCP for configuring eth0. Use a static configuration instead, and don't set a gateway. DHCP is setting a default gateway of the router so your machine uses it for all traffic. Without the gateway being set, it will only use the interface to talk to hosts on that network


Tell the router not to advertise itself as a gateway. This wont be possible on most routers, so this may not be an option at all.


It's possible debian might be able to ignore the gateway setting that the router advertises via DHCP, but I don't use debian, so I'm not sure. This is dependent upon what debian uses to configure network devices.


Also debian specific, you might be able to run a script after the interface is brought up and have it delete the gateway route that is added by DHCP.

  • Debian lets you configure network devices several ways; you can use ifup (traditional Debian way), Network Manager, etc. OP didn't say which he's using. – derobert Mar 28 '13 at 17:45

The easiest way would be something like this:

  1. Disable DHCP on eth0, or down the interface (disconnect it in Network Manager, or use ifdown eth0, etc.)
  2. ip -4 addr add dev eth0
  3. ip link set eth0 up

Alternatively, if you prefer the older ifconfig, I believe that'd be ifconfig eth0 netmask up

Final alternative, if you're using Network Manager (probably the case if you configure your networking using a GUI), set up a profile for eth0 with a static IP address of and a netmask of Leave the default route and DNS servers blank.

After doing any of these, you should be able to ping and also still reach the rest of the Internet.

Why does this work?

(This is a simplification, routing on Linux actually has a lot of optional complexity.) When the kernel wants to send an IP packet, it consults the routing table to determine which interface it sends the packet out of.

The routing table will generally contain a route for the local subnet on each interface. The above commands all put the subnet on eth0. A /30 is 4 IP addresses:– in this case. That conveniently includes your router (.1) and your box (.2). The first (.0 = "network") and last (.3 = "broadcast") addresses in most subnets have a special reserved meaning, so we can't use them.

In addition to the routes for the local subnets, there will be any static routes you've configured, and any routes that come from routing protocols (which doesn't apply to you, or 99% of people).

Finally, there will be a "default" route, which says where to send the rest of the traffic. This route isn't actually special, it's a route for—that is, the entire IPv4 address space. It is default because of how routing lookups work...

By default, it checks in this order:

  1. Is it a local IP address (that is, an IP address of this machine)? If so, route it to myself.
  2. Next, sort all the routes from most-specific (subnet with the fewest IP addresses) to least-specific (subnet with the most IP addresses).
  3. Go down that sorted list, starting from the top, until something matches.
  4. If nothing matches, give up and generate unreachable error.

So your route is default because it gets sorted to the bottom of the list. And your route will be pretty high on the list, if not the very top. Basically it functions as an exception—"send the traffic to the Internet, unless it's for"

What are these weird /30 things?

/X, sometimes called "CIDR notation", is a quick way to specify netmasks. It counts the number of bits set in the metmask. So a netmask of (single IP) is /32, because all bits are set. …254 (two IPs) is /31, …252 is /30, all the way to (all IPv4 addresses) is /0. The common is /24.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.