CentOS IP and DNS settings method detailed _ server other

Source: Internet
Author: User
Tags centos server nameserver

This article describes in detail the IP and DNS setting method under CentOS. Share to everyone for your reference, specific as follows:

1, CentOS 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 Modify the 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 modify 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

Immediate effect:

# ifconfig eth0 192.168.0.2 netmask 255.255.255.0

Start in effect:

Modify/etc/sysconfig/network-scripts/ifcfg-eth0

Modify Gateway Default Gateway

Immediate 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 effective immediately after modification

Modify Host Name

Immediate effect:

# hostname CENTOS1

Start in effect:

Modify/etc/sysconfig/network

Manually change CentOS to static IP

1, the first search, get the following explanation

IP IP Address
Netmark Subnet Mask
Gateway Default Gateways
HostName Host Name
DomainName Domain Name
IP for DNS DNS

2, the files that need to be modified are often

/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/resolv.conf
/etc/hosts

The ' Connect:network is unreachable error ' problem appears and VirtualBox is connected in a bridged adapter way.

Modifying the/etc/sysconfig/network-scripts/ifcfg-eth0 of the virtual machine by modifying the IP address has been network and netmask.

Found to ping with network and netmask, and decided it should be the virtual machine operating system routing configuration problem, try to modify system files directly/etc/sysconfig/network-scripts/route-eth0 add ' Defult via 192.168.0.1′ (192.168.0.1 is the IP address of my router and can be modified according to its own circumstances).

I ran to the/etc/sysconfig/network-scripts/directory and found that the file was not route-eth0, so I created one to add the ' Defult via 192.168.0.1′ to the file.

Run '/etc/init.d/network restart ' reboot network, everything ok! The original problem is really in the route above.

Actually, I used to use the route add command to configure the crossings, but it failed after the reboot, it's a little careless.

I hope this article will help you CentOS server management.

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.