当linux遇上多网卡时

时间:2014-08-05 00:28:28   收藏:0   阅读:304

我虚拟机有三个网卡,有两个在用,分别是不同的网段

  1. eth4: 192.168.100.6/24
  2. eth6: 192.168.137.131/24

 

但是默认系统把我的内部网络eth6设置为所有ip地址需要经过的地方,如下

~ $ip route
192.168.100.0/24 dev eth4 proto kernel scope link src 192.168.100.6
192.168.137.0/24 dev eth6 proto kernel scope link src 192.168.137.131
169.254.0.0/16 dev eth4 scope link metric 1002
169.254.0.0/16 dev eth6 scope link metric 1003
default via 192.168.137.1 dev eth6

 

所以用root身份执行下面的命令

ip route del default
ip route add default via 192.168.100.1
删除默认的default网关接口eth6,添加default到eth4网关,其中default来自centos的/etc/networks文件,default的alias就是0.0.0.0

 

当linux遇上多网卡时,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!