CentOS6上配置静态IP地址、DNS等

问题
默认情况下,CentOS 6安装没有网络接入相关配置,需要你对网络接口进行配置。
解决方案

查看缺省接口配置

接口相关配置保存在/etc/sysconfig/network-scripts目录下,下面显示的是缺省的接口配置。

[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  

配置接口静态地址

# vi /etc/sysconfig/network-scripts/ifcfg-eth0  

DEVICE=eth0
TYPE=Ethernet
UUID=ba6db3a7-4921-414a-ad19-32f1ba035c03
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=192.168.200.122
PREFIX=24
GATEWAY=192.168.200.1
DNS1=192.168.200.13
DNS2=192.168.200.14
DOMAIN=wlyd.local
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no 

配置网关

# vi /etc/sysconfig/network  

NETWORKING=yes
HOSTNAME=RD-CD-APP122.wlyd.local
GATEWAY=192.168.200.1  

重启网络接口

[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 192.168.200.122 is already in use for device eth0...  

[  OK  ] 

配置DNS服务器

# 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命令可以查看当前接口配置信息
参考资料
1. Centos:Interface configuration files

你可能感兴趣的:(操作系统)