Configure static IP addresses and DNS for centos 7

Source: Internet
Author: User

Configure static IP addresses and DNS for centos 7
Configure static IP addresses and DNS for centos 7

 cd /etc/sysconfig/network-scripts/
Find the corresponding Nic configuration and edit it
 vim ifcfg-eno16777736
Configure eno-16777736
TYPE = EthernetBOOTPROTO = static # configure static IP addresses, gateways, subnet Mask IPADDR = subnet mask = 255.255.255.0GATEWAY = 192.168.86.2 cancel networkmanager management NM_CONTROLLED = noDEFROUTE = yesPEERDNS = yesPEERROUTES = route = now.6init = route = bandwidth = noNAME = ed246b2b-cc49-4785-a675-feebf70440e7DEVICE = eno16777736ONBOOT = yes

NM_CONTROLLED = no indicates that the interface is managed through the configuration file instead of the Network Manager. "ONBOOT = yes" indicates that the system will enable this interface at startup.

I configured it in a virtual machine and used a bridge to connect to the network. The IP configuration and gateway can be found in the Virtual Machine editor.

Restart the network service after configuring the static IP address.

systemctl restart network.service

If you ping Baidu, the host cannot be found. If you ping Baidu IP (180.149.132.47), the host can be pinged, indicating that DNS is not configured. Next, configure DNS.

Switch to the networkmanager directory

 cd /etc/NetworkManager/

Add a configuration file for modifying NetworkManager. conf

dns=none

Not managed through network manager

Modify resolv. conf and add dns Configuration

# Primary DNSnameserver 8.8.8.8 # standby DNSnameserver 8.8.4.4

Now ping baidu.com can be pinged.

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.