同时连接多个网络?

在Ubuntu中连接到具有不同子网的多个网络实际上是否需要一些额外的步骤才能正常工作?

我的计算机上有2个网络接口,一个是有线网络接口,另一个是无线USB适配器。 它们都连接到不同子网上的不同路由器。 在你问之前

$ ip -4 a 1: lo:  mtu 16436 qdisc noqueue state UNKNOWN inet 127.0.0.1/8 scope host lo 2: eth0:  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:  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 

我可以ping两个网关IP,但绑定到USB适配器网络的连接永远不会工作。 所以任何想法如何解决这个问题?

找到了解决方案!

事实certificate,我需要为附加的nic添加一个新的路由表,然后在表中为它添加路由规则。 阅读更多信息,了解此链接中的说明

我不确定curl ,但是wget的手册页说:

  --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. 

指定要使用的nic的IP地址。