Virtual Box中 CentOS双网卡设置

Virtual Box中 CentOS双网卡设置:
 
在Virtual Box中安装CentOS x86-64 6.4(final),配置了双网卡,eth0 为桥接模式 , eth1为内网模式
 
配置对应文件: [root@compute1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=08:00:27:6A:0A:50
TYPE=Ethernet
UUID=daed07c6-42df-4d1a-a6dc-15be73161da3
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.137.182
NETMASK=255.255.255.0
GATEWAY=192.168.137.1
DNS1=192.168.137.1
DEFROUTE=yes
 
配置对应文件: [root@compute1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
HWADDR=08:00:27:EF:C0:28
TYPE=Ethernet
UUID=23f6bf7a-6eaf-48e9-8d73-1df8e23d843e
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.1.182
NETMASK=255.255.255.0
DEFROUTE=yes
 
在eth1中不能设置GATEWAY,因为linux GATEWAY的加载是先加载eth0 在加载eth1 这样会覆盖eht0中的GATEWAY。
 
配置文件: [root@compute1 ~]# vi /etc/resolv.conf
nameserver 192.168.137.1
 
修改hostname 为:  compute1
配置文件: [root@compute1 ~]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=compute1
 
配置文件: [root@compute1 ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.137.1 compute1
 

如果不小心在eth1中添加了 GATEWAY,则除了编辑文件 ifcfg-eth1去掉GATWAY之外,还要添加默认路由:
[root@controller1 etc] # route add default gw 192.168.137.1
 
此时路由信息由:
[root@controller1 etc]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1
192.168.137.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     1002   0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1003   0        0 eth1
 
变成了:
[root@controller1 etc]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1
192.168.137.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     1002   0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1003   0        0 eth1
0.0.0.0         192.168.137.1   0.0.0.0         UG    0      0        0 eth0

转载于:https://www.cnblogs.com/Longlycsu/p/3465845.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值