It happens sometimes that you get more than one connection to the internet. Also it might not be usefull in most of the cases, there are few cases when it get really usefull to be able to use the first connection for accessing the Internet and the second connection to access some specific networks or hosts.
Here I’m going to explain how to achieve this setting.
It happens sometimes that you get more than one connection to the internet, for instance, the place I work at, I get one connection using a private internet provider (which is real good), and another one using ADSL from our telecom network. The last one can be accessed using WIFI and allow us to run some specific programs (some dialers like software) which require a telecom connection.
Well, I could have made the choice of only using the wireless connection, but to be honest I rather download my software, packages, iso … at full speed.
So, get let right into the deal.
In this article, I will assume that the wireless connection uses DHCP to retrieve internet settings and is called wlan0, the second connection is called eth0 and is configured using static settings (ip address 188.8.131.52, netmask 255.255.255.0, dns 184.108.40.206 and gateway 220.127.116.11). I want to access internet using eth0 but for networks using IP adresses range 192.168.0.0/16 (192.168.*) and 18.104.22.168/24 (192.169.0.*), i want to use wlan0.
The file where everything happen is /etc/network/interfaces, people which want to know more about this file go read the man interfaces.
So edit /etc/network/interfaces
# The loopback network interface auto lo iface lo inet loopback # This is a list of hotpluggable network interfaces. # They will be activated automatically by the hotplug subsystem. mapping hotplug script grep map eth0 #configuration of wlan0 with dhcp iface wlan0 inet dhcp #configuring wireless setting wireless-essid mywirelessnetwork wireless-key XXXXXXXXXXXXXXXXX #add the route for the wireless interface for specific adresses up route add -net 192.168.0.0/16 gw mywirelessnetwork dev wlan0 up route add -net 22.214.171.124/24 gw mywirelessnetwork dev wlan0 #remove default gateway generated by dhcp up route del default gw mywirelessnetwork #starts automatically at boot up auto wlan0 #configuring eth0 device with static settings iface eth0 inet static address 126.96.36.199 netmask 255.255.255.0 gateway 188.8.131.52 #force to use eth0 dns dns-nameservers 184.108.40.206 #start automatically at boot up auto eth0
Here you are. You might want to restart your network interfaces.
[email protected]$sudo /etc/init.d/networking restart
Now, you can connect to internet with two different connections