Configure static IP for centos7

Source: Internet
Author: User
Centos7 is installed along the way according to the developer type during initial installation. it is already set to bridge mode in vmware. it is said that the network is automatically connected according to DHCP, but it is found that the network card is not activated, record it here. Configure the Nic vim/etc/sysconfig/network-scripts/ifcfg-ens33

Centos7 is installed along the way according to the developer type during initial installation. it is already set to bridge mode in vmware. it is said that the network is automatically connected according to DHCP, but it is found that the network card is not activated, record it here.

Configure the NIC

vim /etc/sysconfig/network-scripts/ifcfg-ens33

The original configuration is as follows:

HWADDR=00:0C:29:2C:E5:30TYPE=EthernetBOOTPROTO=staticDEFROUTE=yesPEERDNS=yesPEERROUTES=yesIPV4_FAILURE_FATAL=noIPV6INIT=yesIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_PEERDNS=yesIPV6_PEERROUTES=yesIPV6_FAILURE_FATAL=noNAME=ens33UUID=ea35e10e-ff50-4a7a-92d5-ab54c58d8b44ONBOOT=no

I did not expect that the NIC will not be started by default in centos7. this is a strange setting, so the NIC is not activated and changed to yes, and then the following parameters are added.

IPADDR=192.168.2.181GATEWAY=192.168.2.1DNS1=114.114.114.114DNS2=8.8.8.8

Here, IPADDR is the Nic address, GATEWAY is the GATEWAY address, and I use the bridge in vmware, so it is the actual router address. DNS1 and DNS2 must be entered at least. Edit/etc/resolv. conf and add

nameserver 114.114.114.114nameserver 8.8.8.8

After configuring the dns in/etc/resolv. conf as shown above

sudo service network restart

In this way, the configuration is ready for Internet access.

Ps: You can also use the system-config-network-tui software to configure it in GUI mode and install it using yum.

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.