bind software to different network interfaces

I have two different network interfaces, connected to 2 networks. One is an eth0 and the other one a wlan0. How can I tell a software to use only a specific interface?

Basically I want Firefox to use eth0 because it is the university lan network and I have to go to intranet sites, the other one is a wifi network open to the internet and I want to bind it to Chrome.

I'm working and I need to use intranet. So eth0 is my choice but eth0 is an intranet without internet access (obviously). Since I want internet access I'm connected to wlan0 (university wifi for students).

The problem is if I have both connected sometimes the browser looks for www.stackoverflow.com using eth0. So I wanted to assign a browser to use only a specific interface.


You cannot bind client software to specific network interfaces, but you can tell the kernel that you only want to use one network interface for some IP addresses and the other one for everything else. This is called "routing", and can be configured using the commands /sbin/route and /sbin/ip.

If I read your question correctly, you want to connect to intranet IP addresses using interface eth0 and to the Internet using interface wlan0.

If you run the command ip route list, you should see an output like the following (numbers will be different, and also you can have more lines in it):

$ ip route list
10.60.44.0/25 dev eth0  proto kernel  scope link  src 10.60.44.39  metric 1 
192.168.80.0/21 dev wlan0  proto kernel  scope link  src 192.168.84.122  metric 2 
[...]
default via 10.60.44.1 dev eth0  proto static 

The first two lines tell you about the networks connected to interfaces eth0 and wlan0: network traffic directed to computers on those networks will be directly sent to them through the corresponding interface.

The last line tells you what the "default route" is: if your computer wants to talk to a computer on a network it is not attached to (e.g., the stackoverflow.com server), it will route traffic via eth0, realying through host 10.60.44.1 (called the "default gateway").

So, to route Internet traffic thorugh wlan0 you should ensure that the last line in the ip route list output reads something like:

default via A.B.C.D dev wlan0 proto static

where A.B.C.D is the IP address of the gateway on the wireless LAN. If the output does not contain "dev wlan0", you can change it with the command:

sudo ip route change to default dev wlan0 via A.B.C.D

You can find out the correct A.B.C.D for wlan0 in two ways:

  1. Look into directory /var/lib/dhcp3/: you should find some dhclient-...-wlan0.lease files. Open the most recent one and search for a line with the string option router in it: the rest of the line tells you the IP address A.B.C.D.

  2. Ask your local network administrators. (Probably the best thing to do, anyway.)

With this configuration, you should be able to:

  • browse the Internet through wlan0
  • browse your Intranet through eth0, provided it is on a single network.

If your intranet spans multiple networks, then you will need to add routes for them - and this is definitely something that requires you to interact with the local network admins. :-)


"ip netns" creates network namespaces. You can then create virtual interfaces (ip link add... veth) and associate them to the namespaces.

The namespaces can be configured to use different routes for example (thus using different interfaces)

Then you can run commands in that namespace, that will use the created namespace.. "ip netns exec NAME cmd..."

Source: http://manpages.ubuntu.com/manpages/saucy/en/man8/ip-netns.8.html