VirtualBox安装CentOS的网络配置
VirtualBox安装CentOS的网络配置
VirtualBox安装CentOS的网络配置
镜像:CentOS-6.4-i386-minimal.iso
安装好后进入系统(是想配置虚拟机里的CentOS既可以和主机互联,同时也可以连上外网),
碰到的错误
使用ping时,错误:
network is unreachable
service network restart时,错误:
Device eth0 does not seem to be present.
开始也是碰上了这些错误提示,
--------------------
自己记录下...
1.先配置好Host-only和Nat,如下图
2.查看文件cat /etc/udev/rules.d/70-persistent-net.rules
01
[root@localhost network-scripts]# cat /etc/udev/rules.d/70-persistent-net.rules
02
# This file was automatically generated by the /lib/udev/write_net_rules
03
# program, run by the persistent-net-generator.rules rules file.
04
#
05
# You can modify it, as long as you keep each rule on a single
06
# line, and change only the value of the NAME= key.
07
08
09
# PCI device 0x8086:0x100e (e1000)
10
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:e2:c7:25", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
11
12
13
# PCI device 0x8086:0x100e (e1000)
14
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:bb:f0:79", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
3.进入 cd /etc/sysconfig/network-scripts目录
3.1 修改目录下的ifcfg-eth0 文件
该文件的DEVICE,HWADDR 应该与/etc/udev/rule.d/70-persistent-net.rules中的eth1一致.
我的ifcfg-eth0 文件,修改后为:
1
[root@localhost network-scripts]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
2
DEVICE=eth1
3
HWADDR=08:00:27:E2:C7:25
4
TYPE=Ethernet
5
UUID=459bb09f-ce67-4276-a510-371dc8b8a12e
6
ONBOOT=yes
7
NM_CONTROLLED=yes
8
BOOTPROTO=dhcp
3.2 修改目录下的ifcfg-eth1 文件(没有则创建)
该文件的DEVICE,HWADDR 应该与/etc/udev/rule.d/70-persistent-net.rules中的eth2一致.
我的ifcfg-eth1 文件,修改后为:
1
[root@localhost network-scripts]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
2
DEVICE=eth2
3
HWADDR=08:00:27:BB:F0:79
4
TYPE=Ethernet
5
UUID=459bb09f-ce67-4276-a510-371dc8b8a12e
6
ONBOOT=yes
7
NM_CONTROLLED=yes
8
BOOTPROTO=dhcp
4.重启服务, service network restart
-----------------------
执行ifconfig命令,输出
01
[root@localhost network-scripts]# ifconfig
02
eth1 Link encap:Ethernet HWaddr 08:00:27:E2:C7:25
03
inet addr:192.168.56.103 Bcast:192.168.56.255 Mask:255.255.255.0
04
inet6 addr: fe80::a00:27ff:fee2:c725/64 Scope:Link
05
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
06
RX packets:924 errors:0 dropped:0 overruns:0 frame:0
07
TX packets:500 errors:0 dropped:0 overruns:0 carrier:0
08
collisions:0 txqueuelen:1000
09
RX bytes:90940 (88.8 KiB) TX bytes:80641 (78.7 KiB)
10
11
12
eth2 Link encap:Ethernet HWaddr 08:00:27:BB:F0:79
13
inet addr:10.0.3.15 Bcast:10.0.3.255 Mask:255.255.255.0
14
inet6 addr: fe80::a00:27ff:febb:f079/64 Scope:Link
15
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
16
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
17
TX packets:13 errors:0 dropped:0 overruns:0 carrier:0
18
collisions:0 txqueuelen:1000
19
RX bytes:1066 (1.0 KiB) TX bytes:1145 (1.1 KiB)
20
21
22
lo Link encap:Local Loopback
23
inet addr:127.0.0.1 Mask:255.0.0.0
24
inet6 addr: ::1/128 Scope:Host
25
UP LOOPBACK RUNNING MTU:16436 Metric:1
26
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
27
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
28
collisions:0 txqueuelen:0
29
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
评论暂时关闭