Configuration of static Ip under centOS7.

Configuration of NAT static network card under centOS7

Recently, large data was built under cenOS7 and the need for centOS7 to configure static IPS was found.This post is about how to configure centOS7's static ip in a VM virtual machine.If there are any deficiencies, we also hope that like-minded people can correct and communicate, and make progress together.

1. Why configure a static ip address in centOS?

This is because the IP address in centOS in the vm changes without restarting. When the virtual machine's IP lease expires, the IP will be reassigned, causing the IP address to change itself.In order to apply convenience and fix the IP address, you need to set the centOS static ip, which is also the solid IP address.

Second, configure static ip in centOS in NAT mode

1. Set the network configuration of the vm virtual machine and set the network card to NAT mode
  • Set the network card type of the virtual machine to NAT mode

  • View virtual network card information in NAT mode.

    Subnet ip:, or centOS, can be set between and
    Subnet mask:

These three are useful when configuring.In particular, the gateway must remember.

2. Set centOS's network adapter to NAT

After CentOS is installed, you can also view the type of network adapter by setting it up.Typically, they are specified at installation time.

3. Modify the configuration file

  • ifconfig view network card information:

  • View default network card information.

General network card information is in the ifcfg-ens33 file under the directory of / etc/sysconfig/network-scripts/
Use the command vi/etc/sysconfig/network-scripts/ifcfg-ens33
View the default network card information as follows:

 TYPE="Ethernet"   # Network Card Type: This defaults to Ethernet
 PROXY_METHOD="none"  # Agent mode
 BOOTPROTO="no"   # static ip
 DEFROUTE="yes"       # Default Route
 IPV4_FAILURE_FATAL="no"   # Turn on IPV4 fatal error detection: No
 IPV6INIT="yes"        # Is ipv6 initialized: Yes
 NAME="ens33"   #Network Card Physical Device Name
 UUID="b4af2f5f-f889-40d6-9058-2eff9f29539b"  # Universal Unique Identification Code for Network Card Information
 DEVICE="ens33"   # Network Card Device Name, Must Ha`NAME`Same
 ONBOOT=no      # Start or not, default:no

The default network card has so much information, in fact, we only need to configure the following information, other use the default.

Set Network Card Boot Protocol to Static


Set up the network card to start by starting up, and configure ip, subnet mask, gateway, domain name information as follows:

 ONBOOT="yes"       # Set to Start Up
 IPADDR=  # ip address, must be on the same network segment as the host
 NETMASK=   # Subnet Mask
 GATEWAY=   # Gateway, where the gateway is the gateway to the virtual machine network card you set up in the first step
 DNS1=       # Server address for domain name resolution, use ipconfig/all on windows to view the address of the local DNS server

Use ipconfig/all under window to view the address of the local DNS server:

The last configured network card information is as follows:


4. Restart the network and verify that the static ip settings are successful.

  • Use the command systemctl restart network to restart the network, Ping other hosts within the network.My Ping is my host.

    [root@localhost /]# ping

  • Other hosts on ping extranet

    [root@localhost /]# ping

The centOS static ip configuration is now complete.##

Tags: network CentOS DNS Windows

Posted on Sat, 27 Jun 2020 19:53:04 -0400 by mikeduke