A tutorial on IP address, DNS, gateway setting and modification in CentOS

Source: Internet
Author: User
Tags centos nameserver

IP address, DNS, gateway settings

[A]dns setting

Modify File vi/etc/resolv.conf
Modify Content
NameServer 114.114.114.114
NameServer 8.8.8.8

[Two]IP settings

Modify File: Vi/etc/sysconfig/network-scripts/ifcfg-eth0
Modify Content
Device=eth0 #描述网卡对应的设备别名, for example, Ifcfg-eth0 in a file that is eth0
Bootproto=static #设置网卡获得ip地址的方式, possible options for STATIC,DHCP or BOOTP, respectively corresponding to statically specified IP address, IP address obtained through DHCP protocol, IP address obtained through BOOTP protocol
broadcast=192.168.1.255 #对应的子网广播地址
hwaddr=00:0c:29:68:ad:61 #对应的网卡物理地址
ipaddr=192.168.1.99 #如果设置网卡获得 IP address is statically specified, this field specifies the IP address of the network adapter
Ipv6init=no
Ipv6_autoconf=no
netmask=255.255.255.0 #网卡对应的网络掩码
network=192.168.1.0 #网卡对应的网络地址
Onboot=yes #系统启动时是否设置此网络接口, when set to Yes, this device is activated when the system starts
dns1=114.114.114.114
dns2=8.8.8.8
Note: In centos6.3 and above version, if the/etc/resolv.conf is set up, the domain name can not be resolved, then the file plus the red part of the face

[Three]gateway Gateway settings

Modify File: Vi/etc/sysconfig/network
Modify Content
Networking=yes #表示系统是否使用网络, generally set to Yes. If set to no, the network cannot be used, and many system services programs will fail to start
Hostname=localhost.localdomain #设置本机的主机名, the host name set here corresponds to the hostname set in/etc/hosts
gateway=192.168.1.253 #ip网关地址, according to your actual situation set

Note:

1 in the VMware virtual machine, through the above settings, and in the network adapter select "Bridging mode" to communicate with your computer system, but also access to the extranet Oh (if you can access the extranet)

2 Linux command to restart Network configuration: Service Network restart

3 The above are modified configuration files, that is, the system will be restarted after the entry into force; some temporary modification methods (reboot system will fail)

Modify IP address ifconfig eth0 192.168.0.2 netmask 255.255.255.0
Modify Gateway route add default GW 192.168.0.1 dev eth0

IP address, DNS, gateway modification

1, CentOS system to modify DNS

To modify the DNS profile of the corresponding network adapter

# vi/etc/resolv.conf

Modify the following content

NameServer 8.8.8.8 #google域名服务器
NameServer 8.8.4.4 #google域名服务器

2. CentOS System Modification Gateway

Modify the configuration file of the gateway for the corresponding network card

[root@centos]# Vi/etc/sysconfig/network

Modify the following content

Networking=yes (Indicates whether the system is using the network, typically set to Yes.) If set to no, the network cannot be used, and many system services programs will not start.
Hostname=centos (sets the host name for this machine, where the host name is set to correspond to the hostname set in/etc/hosts)
gateway=192.168.1.1 (Sets the IP address of the gateway for this computer connection.) For example, the gateway is 10.0.0.2)
3, CentOS system modification IP Address
Modify the configuration file for the IP address of the corresponding network card

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

Modify the following content

Device=eth0 #描述网卡对应的设备别名, for example, Ifcfg-eth0 in a file that is eth0
Bootproto=static #设置网卡获得ip地址的方式, possible options for STATIC,DHCP or BOOTP, respectively corresponding to statically specified IP address, IP address obtained through DHCP protocol, IP address obtained through BOOTP protocol
broadcast=192.168.0.255 #对应的子网广播地址
HWADDR=00:07:E9:05:E8:B4 #对应的网卡物理地址
ipaddr=12.168.1.2 #如果设置网卡获得 IP address is statically specified, this field specifies the IP address of the network adapter
Ipv6init=no
Ipv6_autoconf=no
netmask=255.255.255.0 #网卡对应的网络掩码
network=192.168.1.0 #网卡对应的网络地址
Onboot=yes #系统启动时是否设置此网络接口, when set to Yes, this device is activated when the system starts

4, restart network configuration
 
Service Network restart
or
 
/etc/init.d/network restart
Modify IP Address
takes effect immediately:
 
ifconfig eth0 192.168.0.2 netmask 255.255.255.0
Start effective:
Modify
 
/et C/sysconfig/network-scripts/ifcfg-eth0
Modify Gateway default gateway
immediately takes effect:
 
Route add Default GW 192.168.0.1 Dev eth0
start in effect:
Modify
 
/etc/sysconfig/network
Modify DNS
Modify
 
/etc/resolv. Conf
can be immediately effective after modification, start equally effective
Modify host name
Immediate effect:
&NBSP
hostname centos1
Start effective:
Modify
/etc/sysconfig/n Etwork
CentOS System, we have completed the DNS, gateway, IP address changes, restart the network configuration, we can see the effect of the

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.