The NMCLI of RHEL7 network management

Source: Internet
Author: User

The NetworkManager daemon is used by default in RHEL7 to monitor and manage network settings. NMCLI is the command-line management NetworkManager tool that automatically writes the configuration to the/etc/sysconfig/network-scripts/directory.

Nmcli is a handy tool for configuring your network

such as the following

[[email protected] ~]# nmcli con Show

NAME UUID TYPE DEVICE
System eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 802-3-ethernet eth0
[[email protected] ~]# nmcli con edit "System eth0"
Nmcli> Set ipv4.addresses 192.168.0.100/24 192.168.0.254
Nmcli> Save
Connection ' System eth0 ' (5FB06BD0-0BB0-7FFB-45F1-D6EDD65F3E03) successfully updated.
Nmcli> Activate eth0
Monitoring connection activation (press any key to continue)
Connection successfully activated (D-bus active path:/ORG/FREEDESKTOP/NETWORKMANAGER/ACTIVECONNECTION/1)

Nmcli> quit

OK, the above you have configured the IP address, and already use activate activation, is ready to use, and is automatically written to the configuration file inside, restart also takes effect

If you want to change the existing IP,

[[email protected] ~]# nmcli con Modify "System eth0" ipv4.addresses 192.168.0.200/24

[[email protected] ~]# nmcli con up "System eth0"

As in two orders.

--------------------------------------------------------------------------------------------------------------- --------------------------------------------------------

Above is the command demonstration below to say the principle, in RHEL7 in the network configuration, not as originally is based on the NIC.

In RHEL7 is session-based (connection), a network card can have multiple sessions, but only one session is allowed to be active (active).


What are the benefits of session-based?

For example, the company uses DHCP-assigned IP to connect to the network, and the home uses a static IP address.

At this point I can create two sessions, one using DHCP networking, another with static IP addresses, and at the company activation (active) DHCP, activating static at home.

This eliminates the hassle of frequently modifying IP.

The following is a demonstration of creating and using multiple sessions

1. Create a session, named "Default", which obtains IP through DHCP, automatically connects to the network, the NIC is named eno16777736

[[email protected] ~]# NMCLI connection Add con-name default type Ethernet ifname eno16777736

Connection---session, can be abbreviated to con

Add---

Con-name----"Conversation name, define it yourself.

Type Ethernet---Ethernet card

ifname----"Interface name, which is the NIC name

2. Create another session called "Static" and specify its IP and gateway. However, you cannot automatically connect to the network.

[[email protected] ~]# NMCLI connection add con-name static ifname eno16777736 autoconnect No type Ethernet IP4 192.16 8.0.111/24 gw4 192.168.0.254

3. By default, DHCP connections are used automatically after the system starts, but we can manually change to a static IP session.

[[email protected] ~]# nmcli connection up static

4. Replace DHCP for IP

[[email protected] ~]# NMCLI connection up default

5. Check what is currently in session

[email protected] ~]# NMCLI connection Show

6. Detailed view of the session configuration information, such as viewing the static

[email protected] ~]# NMCLI connection Show "static"

7. View the currently active session

[email protected] ~]# NMCLI connection show--active

--------------------------------------------------------------------------------------------------------------- ---------------------------------------

Modify an existing session

1. Close the session's automatic connection (AutoConnect).

[[email protected] ~]# nmcli con mod "static" Connection.autoconnect no

2. Specify a DNS server address

[[email protected] ~]# nmcli con mod "static" Ipv4.dns 8.8.8.8

3. There are some configuration parameters that can be added and deleted, such as using the + or-number in front of the parameter. For example, add a second DNS server address

[[email protected] ~]# nmcli con mod "static" +ipv4.dns 8.8.4.4

4. Replace the static IP address and the default gateway.

[[email protected] ~]# nmcli con mod "static" ipv4.addresses "192.168.0.120/24 192.168.0.1"

5. Add a second IP

[[email protected] ~]# nmcli con mod "static" +ipv4.addresses 192.168.0.130/24

Note: The configuration modified by Nmcli Con mod is automatically saved as a configuration file and will still be valid after a reboot, but if the configuration changes, you need to reactivate it to make the new configuration effective.

[[email protected] ~]# nmcli con up "static"

add: Check the IP address in rhel7 to use

[[Email protected] ~]# IP addr----"can be abbreviated to IP a

View your own routes can be used

[[Email protected] ~]# IP route

via:https://www.rhel.cc/2014/11/82/

The NMCLI of RHEL7 network management

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.