CentOS modifies host name and network information

Source: Internet
Author: User
Tags nameserver

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.