How to configure static IP addresses and dns in centos

Source: Internet
Author: User
Tags centos


Generally, dncp is not configured in the production environment. It is usually configured once, once and for all. Then, write down how to configure the static address:

Nic configuration files are placed under/etc/sysconfig/network-scripts, you can see ifcfg-eth0, ifcfg-eth1 .... These are the Nic configuration files we are looking. Before configuring the network card, you must first understand the configuration parameters of the network card.


* DEVICE interface name (DEVICE, NIC)

* USERCTL [yes | no] (whether non-root users can control the device)

* [None | static | bootp | dhcp] (Protocol not used during boot | static IP allocation | BOOTP protocol | DHCP protocol)

* Hwaddr mac address

* Whether the network interface is valid when the ONBOOT system is started (yes/no)

* TYPE network TYPE (usually Ethemet)

* NETMASK network mask

* PREFIX verification code length

* Ipaddr ip address

* GATEWAY default gateway ip address

* BROADCAST address

* NETWORK address

Looking at a bunch of things, you don't need to write so much. Just write a few. For example:


Okay, enough. Restart the NIC:


Service network restart

How about whether the network is smooth.


By the way, you also need to configure dns. You can add DNS1 = 8.8.8.8 and DNS2 = 114.114.114.114 to the above Nic file.

You can also add rows of nameserver 8.8.8.8 in/etc/resolv. conf (multiple rows can be added ).


In addition, if dns is configured like this, you may find a line of service network restart

The configured dns is missing again. Tips: close the networkmanager service.

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.