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.

Does connecting to multiple networks with different subnet in Ubuntu actually require some extra steps to work correctly?

I have 2 network interfaces on my computer, one is wired nic and the other is wireless USB adapter. Both of them are connected to different routers on different subnet. Before you ask

$ ip -4 a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet 10.10.1.2/24 brd 10.10.1.255 scope global eth0
4: wlan1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    inet 192.168.1.2/24 brd 192.168.1.255 scope global wlan1

$ ip -4 r
default via 10.10.1.1 dev eth0  proto static 
10.10.1.0/24 dev eth0  proto kernel  scope link  src 10.10.1.2  metric 1 
169.254.0.0/16 dev eth0  scope link  metric 1000 
192.168.1.0/24 dev wlan1  proto kernel  scope link  src 192.168.1.2  metric 2 

$ netstat -rn output
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         10.10.1.1       0.0.0.0         UG        0 0          0 eth0
10.10.1.0       0.0.0.0         255.255.255.0   U         0 0          0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 wlan1

I can ping both of the gateway IP fine but binding a connection to the USB adapter network never work. So any idea how to fix this?

share|improve this question
add comment

2 Answers

I'm not sure about curl, but wget's man page says:

   --bind-address=ADDRESS
       When making client TCP/IP connections, bind to ADDRESS on the local
       machine.  ADDRESS may be specified as a hostname or IP address.
       This option can be useful if your machine is bound to multiple IPs.

Specify the IP address of the nic you want to use.

share|improve this answer
    
I know how to bind interface :) –  Flint Jun 17 '12 at 2:48
add comment
up vote 0 down vote accepted

FOUND THE SOLUTION!

Turns out that I need to add a new routing table for the additional nic and then add routing rules for it in the table. Read more for instructions in this link

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.