To configure a DNS gateway with a specified IP address in the CentOS system

Source: Internet
Author: User
Tags centos nameserver

1. Environment

System hardware: CPU: 2x2 cores, 2 GB memory
System version: Centos-6.5-x86_64
Router Gateway: 192.168.1.1

2. View network MAC

[Root @ centos ~] # Cat/etc/udev/rules. d/70-persistent-net.rules
The following information is displayed:
# PCI device 0x15ad: 0x07b0 (vmxnet3)
SUBSYSTEM = "net", ACTION = "add", DRIVERS = "? * ", ATTR {address} =" 00: 50: 56: 94: 04: 3c ", ATTR {type} =" 1 & Prime ;, KERNEL = "eth *", NAME = "eth0 & Prime;
# PCI device 0x15ad: 0x07b0 (vmxnet3)
SUBSYSTEM = "net", ACTION = "add", DRIVERS = "? * ", ATTR {address} =" 00: 50: 56: 94: 53: 24 & Prime;, ATTR {type} = "1 & Prime ;, KERNEL = "eth *", NAME = "eth1 & Prime;
Eth0: corresponds to the first Nic, and eth1: The second Nic. Currently, eth0 is used to connect to the vro, and eth1 is retained (the server is generally used to connect to other hosts)

3. Modify host name

[Root @ centos ~] # Vim/etc/sysconfig/network
Open the file, modify the following content, and save
NETWORKING = yes # use the network
HOSTNAME = centos # Set host name

4. Modify the NIC

[Root @ centos ~] # Vim/etc/sysconfig/network-scripts/ifcfg-eth0
Open the file, modify the following content, and save
DEVICE = eth0 # corresponds to the first Nic
TYPE = Ethernet
ONBOOT = yes # run at startup
NM_CONTROLLED = yes
BOOTPROTO = static # use a static IP address instead of an IP address allocated by DHCP
DEFROUTE = yes
20174_failure_fatal = yes
IPV6INIT = no
NAME = "System eth0 & Prime; # NAME
HWADDR = 00: 50: 56: 94: 04: 3C # it must correspond to the MAC address of etho (/etc/udev/rules. d/70-persistent-net.rules)
PEERDNS = yes
PEERROUTES = yes
IPADDR = 192.168.1.100 # specify the local IP address
NETMASK = 255.255.255.0 # specify the subnet mask
GATEWAY = 192.168.1.1 # specify the GATEWAY
5. Modify DNS
[Root @ centos ~] # Vim/etc/resolv. conf

Open the file, modify the following content, and save

Nameserver 8.8.8.8 # GOOGLE's DNS server
Nameserver 202.106.0.20 # specify the nearest DNS server in the current city (different cities, in Beijing)
Nameserver 192.168.1.1 # specify the DNS server specified on the router

6. Restart the network configuration.

[Root @ centos ~] # Service network restart

7. Restart

[Root @ centos ~] # Shutdown-r now

8. View current IP settings

[Root @ centos ~] # Ifconfig

9. Test whether to connect to the Internet

[Root @ centos ~] # Ping www.111cn.net

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.