Configure static IP addresses in CentOS 7

Source: Internet
Author: User

Configure static IP addresses in CentOS 7

If you want to set a static IP address for a network interface in CentOS 7, there are several different methods, depending on whether you want to use the network manager.

Network Manager is a dynamic Network controller and configuration system. It is used to enable and activate a device and connection when a Network device is available. By default, CentOS/RHEL 7 is installed with a network manager and enabled.

Run the following command to verify the status of the Network Manager Service:

$ systemctl status NetworkManager.service

Run the following command to check the network interfaces managed by the Network Manager:

$ nmcli dev status

If the output result of nmcli of an interface is "connected" (such as enp0s3 in this example), the interface is managed by the Network Manager. You can easily disable the network manager for a specific interface so that you can configure a static IP address for it.

The following describesYou can configure static IP addresses for network interfaces on CentOS 7. In this example, we will configure the network interfaces named enp0s3.

Do not use network management to configure static IP addresses

Go to the/etc/sysconfig/network-scripts directory and find the configuration file (ifcfg-enp0s3) for this interface ). If not, create one.

Open the configuration file and edit the following variables:

In, "NM_CONTROLLED = no" indicates that this interface will be set through this configuration file, instead of being managed through the network manager. "ONBOOT = yes" tells us that the system will enable this interface at startup.

Save the changes and run the following command to restart the network service:

# systemctl restart network.service

Verify that the interface is correctly configured:

# ip add

Use Network Manager to configure static IP addresses

If you want to use the network manager to manage this interface, you can use nmtui (Network Manager text User Interface), which allows you to configure the network manager in the terminal environment.

Before using nmtui, set "NM_CONTROLLED = yes" in the/etc/sysconfig/network-scripts/ifcfg-enp0s3 ".

Now, install nmtui as follows.

# yum install NetworkManager-tui

Then, edit the Network Manager Configuration of the enp0s3 interface:

# nmtui edit enp0s3

On the screen below, we can manually enter the same information as the content contained in/etc/sysconfig/network-scripts/ifcfg-enp0s3.

Use the arrow keys to navigate to the screen, press enter to select the content in the Value List (or enter the desired content), and then click OK on the right at the bottom of the screen.

Finally, restart the network service.

# systemctl restart network.service

Now everything is done.

Via: http://ask.xmodulo.com/configure-static-ip-address-centos7.html

Translator: GOLinux Proofreader: wxy

This article was originally translated by LCTT and launched with the Linux honor in China

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.