centos6 网络配置
问题
默认情况下,CentOS 6安装没有网络接入相关配置,需要你对网络接口进行配置。
解决方案
查看缺省接口配置
接口相关配置保存在/etc/sysconfig/network-scripts目录下,下面显示的是缺省的接口配置。
[plain] view plain copy
-
[root@CentOS65 network-scripts]# more /etc/sysconfig/network-scripts/ifcfg-eth0
-
DEVICE=eth0
-
HWADDR=00:0C:29:C1:48:03
-
TYPE=Ethernet
-
UUID=b2bbb718-caa6-46c3-ae12-587cbedfd5fa
-
ONBOOT=no
-
NM_CONTROLLED=yes
-
BOOTPROTO=dhcp
配置接口静态地址
[plain] view plain copy
-
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
-
-
DEVICE="eth0"
-
NM_CONTROLLED="yes"
-
ONBOOT=yes
-
HWADDR=A4:BA:DB:37:F1:04
-
TYPE=Ethernet
-
BOOTPROTO=static
-
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
-
IPADDR=10.220.33.108
-
NETMASK=255.255.255.0
配置网关
[plain] view plain copy
-
# vi /etc/sysconfig/network
-
-
NETWORKING=yes
-
HOSTNAME=centos6
-
GATEWAY=10.220.33.1
重启网络接口
[plain] view plain copy
-
[root@CentOS65 network-scripts]# /etc/rc.d/init.d/network restart
-
Shutting down interface eth0: [ OK ]
-
Shutting down loopback interface: [ OK ]
-
Bringing up loopback interface: [ OK ]
-
Bringing up interface eth0: Determining if ip address 10.220.33.108 is already in use for device eth0...
-
-
[ OK ]
配置DNS服务器
[plain] view plain copy
-
# vi /etc/resolv.conf
-
-
nameserver x.x.x.x # Replace with your nameserver ip
-
nameserver y.y.y.y # Replace with your nameserver ip
查看接口配置
使用"ip a"或ifconfig命令可以查看当前接口配置信息
发表评论