Centos 6.8下虛擬機(jī)網(wǎng)絡(luò)配置教程
標(biāo)簽:centos 6.8 網(wǎng)絡(luò)配置實(shí)例
主題:centos 6.8 下網(wǎng)絡(luò)配置方法(網(wǎng)關(guān)、dns、ip地址配置)
1. 配置DNS
# vi /etc/resolv.conf 加入:
代碼如下:
nameserver 192.168.0.1
nameserver 8.8.8.8
nameserver 8.8.4.4
2. 配置網(wǎng)關(guān)
# 配置網(wǎng)關(guān):(可以忽略該步驟)
vi /etc/sysconfig/network
加入:
GATEWAY=192.168.0.1
完整的如下:
代碼如下:
NETWORKING=yes
HOSTNAME=localhost.localdomain
GATEWAY=192.168.0.1
3. 配置網(wǎng)卡地址
# 配置虛擬機(jī)的網(wǎng)卡IP信息
vi /etc/sysconfig/network-scripts/ifcfg-eth0
# 內(nèi)容如下:
代碼如下:
DEVICE="eth0"
HWADDR="00:0C:29:6C:BB:E6"
NM_CONTROLLED="yes"
ONBOOT="no"
NETMASK=255.255.255.0
IPADDR=192.168.0.8
GATEWAY=192.168.0.1
BOOTPROTO=static
ONBOOT=yes
PEERDNS=yes
# 查看網(wǎng)卡信息
ifconfig
ifconfig -a
[root@chao ~]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0C:29:D5:80:99
inet addr:192.168.1.37 Bcast:192.168.1.255 Mask:255.255.254.0
inet6 addr: fe80::20c:29ff:fed5:8099/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8740 errors:0 dropped:0 overruns:0 frame:0
TX packets:359 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:691234 (675.0 KiB) TX bytes:196651 (192.0 KiB)
Interrupt:19 Base address:0x2000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:785 errors:0 dropped:0 overruns:0 frame:0
TX packets:785 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:318089 (310.6 KiB) TX bytes:318089 (310.6 KiB)
4. 重新啟動服務(wù)
# 復(fù)制代碼
代碼如下:
/etc/init.d/network restart
或使用命令:
service network restart
或:
ifdown eth0 and ifup eth0
配置完成后,ping一下網(wǎng)關(guān),檢查是否能ping通或在用ifconfig eth0,檢查下實(shí)際配置的ip地址。