1. Modify the host name
[[email protected] ~]# Vim/etc/sysconfig/network Open the file, modify the following and save
Networking=yes #使用网络
Hostname=centos #设置主机名称
[Email protected] ~]# hostname CentOS #立即生效
2. Modify the NIC
[Email protected] ~]# Vim/etc/sysconfig/network-scripts/ifcfg-eth0
Open the file, modify the following and save
Device=eth0 #对应第一张网卡
type=ethernet
Onboot=yes #是否启动时运行
Nm_controlled=yes
bootproto=static #使用静态IP instead of assigning IP by DHCP
Defroute=yes
Ipv4_failure_fatal=yes
Ipv6init=no
name= "System eth0" #名称
hwaddr=00:50:56:94:04:3c #必须对应etho是的MAC地址 (/etc/udev/rules.d/70-persistent-net.rules)
Peerdns=yes
Peerroutes=yes
ipaddr=192.168.1.128 #指定本机IP地址
netmask=255.255.255.0 #指定子网掩码
gateway=192.168.1.2 #指定网关
dns1=192.168.1.2
3. Modify DNS
[email protected] ~]# vim/etc/resolv.conf
Open the file, modify the following and save
NameServer 8.8.8.8 #GOOGLE的DNS服务器
NameServer 192.168.1.2 #指定经路由器上指定的DNS服务器
4. Restart the network configuration
[[Email protected] ~] #service Network restart
5. Restart
[[Email protected] ~] #reboot
6. View current IP Settings
[Email protected] ~]# ifconfig
7. Test whether to connect the external network
[[email protected] ~]# Ping www.baidu.com
CentOS modifies host name and network information