Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

My Ubuntu 12.10 box has two network cards, Ethernet card (Eth0) is connected to internal network (192.168.18.0/24) without any internet access, Wireless card (Wlan0) is connected to intranet (10.124.64.0, 255.255.252.0) which has internet access. When I try to access internet, I have to disable Ethernet card (Eth0). Is there any way to config ip route from Ubuntu, something like 0.0.0.0 0.0.0.0 Wlan0, so I can access internet without disable Ethernet 0 card. Thanks for your help.

Kevin

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

First use the route command to find out what your current routing table looks like. It will probably look somewhat like this:

$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.18.1    0.0.0.0         UG    0      0        0 eth0
192.168.18.0    *               255.255.255.0   U     1      0        0 eth0
10.124.64.0     *               255.255.255.0   U     1      0        0 wlan0
...

Now you will want to replace the default gateway by a gateway on the 10.124.64/24 net. You can find out its IP by running route when eth0 is disabled or unplugged. Assuming it is the .1, you would then execute:

route del default
route add default gw 10.124.64.1

If you want to automate this, you could add these commands to an up statement in the appropriate stanza in /etc/network/interfaces (see man interfaces).


DISCLAIMER: route is considered old fashioned and I ought to be doing this using the ip route command; the effect however is identical. Also, adding an up statement to /etc/network/interfaces may be perceived by some as pre-historic. I'll be happy to upgrade my knowledge.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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