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.

I have set up a bridge connection from my mobile phone connected via USB to my laptop running Ubuntu 12.04 to another computer connected via ethernet cable. The bridge thus connects usb0 and eth0. I set it up by typing following commands on my laptop:

$ ifconfig usb0 0.0.0.0 promisc up
$ brctl addbr br0
$ brctl addif br0 usb0 eth0
$ ifconfig br0 up

Now the other computer (connected to my laptop via ethernet) can connect to the internet. I now use following commands to restore the internet connection on my laptop:

$ ifconfig br0 192.168.42.200 up
$ route del default
$ route add default gw 192.168.42.129 br0

After this operation, route prints the following kernel ip routing table:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.42.129  0.0.0.0         UG    0      0        0 br0
link-local      *               255.255.0.0     U     1000   0        0 usb0
192.168.42.0    *               255.255.255.0   U     0      0        0 br0
192.168.42.0    *               255.255.255.0   U     1      0        0 usb0

Everything works fine, both computers can connect to the internet, but then suddenly my laptop looses the connection.

I found that this happens because the kernel ip routing table was modified. route now gives following output:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.42.129  0.0.0.0         UG    0      0        0 usb0
link-local      *               255.255.0.0     U     1000   0        0 usb0
192.168.42.0    *               255.255.255.0   U     1      0        0 usb0

Apparently Ubuntu does not like to be connected via br0 and thus switches back to usb0. The connection can be restored though, by again resetting the route table:

$ route del default
$ route add default gw 192.168.42.129 br0

Unfortunately, after a few moments the connection is lost again. Once it would even last for 5 minutes before Ubuntu decided to kill it again.

How can I prevent Ubuntu from modifying the kernel ip routing table?

share|improve this question
    
Ok, I finally found a solution. Unfortunately I do not have enough reputation to post it immediately, as an answer. askubuntu told me I will have to wait for 8 hours before I can answer my own question. Once this delay is over I will post my solution. –  kassiopeia Mar 4 '13 at 11:14

1 Answer 1

up vote 1 down vote accepted

Ok, in case anyone else has the same problem, here is how I solved it: I simply disabled the network manager by typing following command:

$ stop network-manager

Note that the network manager clears the routing table and brings down all connections before it exits, so you have to bring back up all interfaces that you need.

I had to additionally type following commands for my bridge to work again:

$ ifconfig usb0 up
$ ifconfig eth0 up

Further I needed to edit /etc/resolv.conf to get address resolution back to work. I added following lines, which sets the Google DNS servers as nameservers:

nameserver 8.8.8.8
nameserver 8.8.4.4

Now everything works as expected, both computers have internet connection.

share|improve this answer

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.