解决LINUX 双网卡无法上网问题小记

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解决LINUX 双网卡无法上网问题小记相关的知识,希望对你有一定的参考价值。

场景:

教室的电脑网段是172.16.30.0/24      一些学习资料和yum源的ip是172.16.8.100

默认的情况下教室的电脑是可以互通以及连接教学ftp172.16.8.100

现在需要上网可是用安卓手机usb共享电脑上网后发现,172.16.30.0网段是通的,但就是上不了网,要上网就只能禁用eth0

网卡:

电脑eth0  通过网线连接内网  172.16.30.0/24     网关172.16.30.254

手机usb0  通过wifi连接外网  192.168.42.0/24    网关192.168.42.129

最终效果:电脑连接老师VNC 正常连接教学资料ftp:172.16.8.100 正常 连接外网正常

技术分享

包括kvm里192.168.122.0 网段也可以连通ftp了  而且连通外网正常

解决过程:

[[email protected] ~]# route       #查看路由表
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.16.30.0     *               255.255.255.0   U     1      0        0 eth0
192.168.42.0    *               255.255.255.0   U     1      0        0 usb0
192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0
default         bogon           0.0.0.0         UG    0      0        0 eth0
[[email protected] ~]# route add default gw 192.168.42.129  #添加网关
[[email protected] ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.16.30.0     *               255.255.255.0   U     1      0        0 eth0
192.168.42.0    *               255.255.255.0   U     1      0        0 usb0
192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0
default         bogon           0.0.0.0         UG    0      0        0 usb0
default         bogon           0.0.0.0         UG    0      0        0 eth0
[[email protected] ~]# route add -net 192.168.42.0 netmask 255.255.255.0 dev usb0  #设置192.168.42.0网段默认使用usb0网卡
[[email protected] ~]# ping 172.16.8.100   #这个时候还是不通
PING 172.16.8.100 (172.16.8.100) 56(84) bytes of data.
^C
--- 172.16.8.100 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1437ms

[[email protected] ~]# route add -net 172.16.8.0 netmask 255.255.255.0 dev eth0  #设置172.16.8.0网段默认使用eth0网卡     
[[email protected] ~]# ping 172.16.8.100
PING 172.16.8.100 (172.16.8.100) 56(84) bytes of data.
64 bytes from 172.16.8.100: icmp_seq=1 ttl=63 time=2.60 ms
^C
--- 172.16.8.100 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 934ms
rtt min/avg/max/mdev = 2.609/2.609/2.609/0.000 ms
[[email protected] ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.16.30.0     *               255.255.255.0   U     1      0        0 eth0
192.168.42.0    *               255.255.255.0   U     0      0        0 usb0
192.168.42.0    *               255.255.255.0   U     1      0        0 usb0
172.16.8.0      *               255.255.255.0   U     0      0        0 eth0
192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0
default         bogon           0.0.0.0         UG    0      0        0 usb0
default         bogon           0.0.0.0         UG    0      0        0 eth0
[[email protected] ~]#

首发地址:幽龙博客http://www.3glong.com/post-59.html

本文出自 “幽龙博客” 博客,请务必保留此出处http://3glong.blog.51cto.com/11271871/1774298

以上是关于解决LINUX 双网卡无法上网问题小记的主要内容,如果未能解决你的问题,请参考以下文章

centos 6.5 双网卡 上网

关于Linux系统下设置双网卡双IP的问题!

ubuntu 12.04与windows7 双系统,在ubuntu下,无法有线上网,插入网线灯不亮;无线正常;

vmware克隆linux虚拟机网卡无法上网的解决办法

linux 双网卡代理上网

关于双网卡互连问题,求教高手