ryanbaw
ryanbaw
2020-06-29 08:59
采纳率: 0%
浏览 252

多网卡如何指定访问外网的网卡?

Linux下有多个网卡,其中以太网都不能访问外网,现在想通过无线网卡连接手机热点的方式访问外网。请问该如何配置?

网卡信息如下,其中eth0和eth1都无法访问外网,wlan0连接到了手机热点,但由于路由的原因,无法通过wlan0上网。

pi@raspberrypi:~ $ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.206.107  netmask 255.255.255.0  broadcast 192.168.206.255
        inet6 fe80::6153:d3d5:f40c:e360  prefixlen 64  scopeid 0x20<link>
        ether dc:a6:32:24:f4:3b  txqueuelen 1000  (Ethernet)
        RX packets 517198  bytes 66230878 (63.1 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 248919  bytes 110049145 (104.9 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.50.6  netmask 255.255.255.0  broadcast 192.168.50.255
        inet6 fe80::bf96:bca8:ec4b:a459  prefixlen 64  scopeid 0x20<link>
        ether 00:e0:4c:68:01:d4  txqueuelen 1000  (Ethernet)
        RX packets 2212  bytes 200838 (196.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4939  bytes 4983497 (4.7 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 2976  bytes 189237 (184.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2976  bytes 189237 (184.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.43.223  netmask 255.255.255.0  broadcast 192.168.43.255
        inet6 fe80::cb40:c83:2d97:bb9b  prefixlen 64  scopeid 0x20<link>
        ether dc:a6:32:24:f4:3c  txqueuelen 1000  (Ethernet)
        RX packets 28325  bytes 28200107 (26.8 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 68749  bytes 14023362 (13.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

pi@raspberrypi:~ $ ip route
default via 192.168.206.254 dev eth0 proto dhcp src 192.168.206.107 metric 202
default via 192.168.50.1 dev eth1 proto dhcp src 192.168.50.6 metric 203
default via 192.168.43.1 dev wlan0 proto dhcp src 192.168.43.223 metric 304
192.168.43.0/24 dev wlan0 proto dhcp scope link src 192.168.43.223 metric 304
192.168.50.0/24 dev eth1 proto dhcp scope link src 192.168.50.6 metric 203
192.168.206.0/24 dev eth0 proto dhcp scope link src 192.168.206.107 metric 202
pi@raspberrypi:~ $ cat /etc/resolv.conf
# Generated by resolvconf
domain whoisyourdaddy.com
nameserver 127.0.0.1
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • body221
    body221 2020-06-29 09:53

    配置wlan0为缺省路由,其他的内网使用其他两个网口

    点赞 评论

相关推荐