Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My Ubuntu machine is connected to internet via wifi, and also connected to LAN by ethernet cable. Every time I log on, I have to run these 2 commands in order to set the proper gateway (wlan0 in my case) so that I can access internet.

% sudo route del default
% sudo route add default gw

To automate, I've tried several things that I've found on internet but didn't work so far. Though can't remember all of them, one of them is this:

(In /etc/network/interfaces, add the followings and reboot)
up route del default 
up route add -net gw dev wlan0

The result of route command right after boot (before running the operation shown above, 10.0.* is LAN) shows that eth0 is still set default gw against my desire:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface      *        U     1      0        0 eth0    *        U     2      0        0 wlan0
link-local      *          U     1000   0        0 eth0
default         UG    0      0        0 eth0

I use Ubuntu 11.04

Has anyone got a direct solution?

Update 10/22/11) Since I might have changed many configurations, I don't know only these changes are the ones that take effect, but here are my solution. Now the computer allows both internet (wlan0) and local (eth0) on boot.

  • (as the chosen answer indicates) Check both "Ignore automatically obtained routes" & "use this connection only for resources on its network"

  • Modify /etc/network/interfaces as follows:

    auto lo iface lo inet loopback up route del default up route add -net gw dev wlan0

share|improve this question

migrated from Sep 12 '11 at 14:27

This question came from our site for professional and enthusiast programmers.

have you tried altering settings in edit wireless/wired connections after ubuntu starts? – BlackDivine Sep 12 '11 at 14:18
@IsaacS is this a client or server that you are having an issue with? If a client - I presume you are asking how to configure Network Manager via its GUI? – fossfreedom Sep 12 '11 at 14:44
@BlackDivine thx, but I guess I don't know what "edit wireless/wired connections" you mentioned means.. – IsaacS Sep 12 '11 at 15:01
@fossfreedom thx, I think I should respond as "client". This is what I use as desktop computer with GUI. I don't mind the solution is either via commandline or GUI. – IsaacS Sep 12 '11 at 15:03
up vote 1 down vote accepted
  1. Click your network icon
  2. Edit connections.
  3. Select the first wired connection (eth0)
  4. Edit
  5. In the IPv4 settings, click Routes.
  6. Check the bottom box.

I think that should do it, but I haven't actually tried it myself, so it would be nice with a comfirmation.

share|improve this answer
Thanks. If the "bottom box" in the step 6 is "Use this connection only for resources on its network", then unfortunately checking it (and reboot) didn't change the situation as I tried just now. – IsaacS Sep 12 '11 at 15:10
I don't use English, so I don't recall exactly what it says. :) Perhaps you can also ignore automatically discovered routes? I seem to remember having done something like that once. – Jo-Erlend Schinstad Sep 12 '11 at 16:03
Thanks again. I checked both checkboxes and rebooted OS but no good. – IsaacS Sep 16 '11 at 0:50
as I updated my original question, I somehow solved the issue, based upon your hints. Thanks! – IsaacS Oct 23 '11 at 4:38

Your Answer


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.