|
Red Hat Enterprise Linux 7 and CentOS 7 default network services provided by NetworkManager, which is the guardian of the process control and dynamic configuration of the network, which is used to keep the current network equipment and connection in working condition, but also supports the traditional type of configuration ifcfg file.
NetworkManager can be used for the following types of connections: Ethernet, VLANS, Bridges, Bonds, Teams, Wi-Fi, mobile boradband (mobile 3G) and IP-over-InfiniBand. For these types of networks, NetworkManager can configure their network aliases, IP address, static routing, DNS, VPN connections, and many other special parameters.
You can use the command-line tool to control nmcli NetworkManager.
nmcli Usage
# Nmcli [OPTIONS] OBJECT {COMMAND | help}
We can TAB key to complete the command, when you forget the syntax of the command just press TAB you can see the list of options.
Some examples of the use of nmcli:
# Nmcli general status
This command will NetworkManager all states are printed.
# Nmcli connection show
Show all connections.
# Nmcli connection show -a
Display only currently active connections.
# Nmcli device status
Lists NetworkManager identified a list of devices and their status.
Start / stop network interfaces
Use nmcli tool to start or stop network interfaces, and the ifconfig up / down is the same.
Use the following command to stop an interface:
# Nmcli device disconnect eno16777736
The following command to enable the interface:
# Nmcli device connect eno16777736
Add a static IP Ethernet connections
The following command to add a static IP address for Ethernet connection:
# Nmcli connection add type ethernet con-name NAME_OF_CONNECTION ifname interface-name ip4 IP_ADDRESS gw4 GW_ADDRESS
Change NAME_OF_CONNECTION, IP_ADDRESS, GW_ADDRESS parameter (if not the gateway, then you can omit the last part) according to your desired configuration.
# Nmcli connection add type ethernet con-name NEW ifname eno16777736 ip4 192.168.1.141 gw4 192.168.1.1
Use the following command to set the DNS server:
# Nmcli connection modify NEW ipv4.dns "8.8.8.8 8.8.4.4"
The following command starts a new Ethernet connection:
# Nmcli connection up NEW ifname eno16777736
Check the configuration of the new connection:
# Nmcli -p connection show NEW
Add a new connection using DHCP
Add a new connection that uses DHCP to automatically assign IP address, gateway, DNS, etc., you have to do is to command line ip / gw address part removed on the line, DHCP automatically assigns these parameters.
Example, in the eno 16777736 configure a device called a DHCP connection NEW_DHCP
# Nmcli connection add type ethernet con-name NEW_DHCP ifname eno16777736 |
|
|
|