Network configuration of nmcli
Use the nmcli command to configure the network
NetworkManager is a daemon that manages and monitors network settings. The device is the network interface, and the connection is the configuration of the network interface. , a network interface can have multiple connection configurations, but only one connection configuration is effective at the same time.
1 Configure the host name
CentOS6 previous host configuration file:/etc/sysconfig/network
CentOS7 host name configuration File: /etc/hostname. This file does not exist by default. The host name is obtained through DNS reverse resolution. The host name defaults to: localhost.localdomain
Display host name information
hostname
Hostnamectl status
Create and modify the file and take effect
hostnamectl set-hostname deskX.example.com
[root@centos73 ~]# hostnamectl set-hostname centos7.3.com [root@centos73 ~]# hostname centos7.3.com [root@centos73 ~]# cat /etc/hostname centos7.3.com
You can see that the modification has been successful .
Delete Files. Reply to the default host name localhost.localdomain
2 Common commands
nmcli connection show Show all connections
nmcli connection show - -active Display all active connection status
nmcli connection show "ens33" Display network connection configuration
nmcli device status Display device status
nmcli device show ens33 Display network interface properties
nmcli connection add help View help
nmcli connection reload Reload configuration
nmcli connection down test2 Disable the configuration of test2. Note that a network card can have multiple configurations.
nmcli connection up test2 Enable test2 configuration
nmcli device disconnect ens33 Disable ens33 network card, physical network card
nmcli device disconnect ens33 Enable ens33 network card
Graphic tool
nm-connection-editor
Character tool
nmtui
nmtui-connect
nmtui-edit
nmtui-hostname
3 Create a new connection configuration
(1 ) Create a new connection configuration default, IP automatically obtained through DHCP
[root@centos73 ~]# nmcli connection add con-name default type Ethernet ifname eth0 Connection 'default' (d62f98af-86ed-4735-80aa-2d80351765b2) successfully added.
Delete connection
[root@centos73 ~]# nmcli connection delete default Connection 'default' (d62f98af-86ed-4735-80aa-2d80351765b2) successfully deleted.
(2) Create New connection configuration test2, specify static IP, do not automatically connect
[root@centos73 ~]# nmcli connection add con-name test2 ipv4.method manual ifname ens33 autoconnect no type Ethernet ipv4.addresses 172.25.100.100/24 gw4 172.25.100.1 Connection 'test2' (98385bf5-8cc3-47e3-a5f2-51e2d736be6d) successfully added.
Parameter description:
con-name specifies the connection name, no special requirements,
ipv4.methmod specifies the way to obtain the IP address
ifname specifies the network card name, which is the network card that this configuration takes effect
autoconnect specifies whether to start automatically
ipv4.addresses Specify IPv4 address
gw4 specifies gateway
4View the /etc/sysconfig/network-scripts/ directory
You will see an extra file ifcfg-test2. The addition has indeed taken effect.
/etc/sysconfig/network-scripts/ifcfg-test2
[root@centos73 ~]# ls /etc/sysconfig/network-scripts/ifcfg-* /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-lo /etc/sysconfig/network-scripts/ifcfg-ens34 /etc/sysconfig/network-scripts/ifcfg-test2
##5 Enable test2 connection configuration
[root@centos73 ~]# nmcli connection up test2 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7) [root@centos73 ~]# systemctl restart network
[root@centos73 ~]# nmcli device show ens33 GENERAL.DEVICE: ens33 GENERAL.TYPE: ethernet GENERAL.HWADDR: 00:0C:29:3A:00:82 GENERAL.MTU: 1500 GENERAL.STATE: 100 (connected) GENERAL.CONNECTION: test2 GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/7 WIRED-PROPERTIES.CARRIER: on IP4.ADDRESS[1]: 172.25.100.100/24 IP4.GATEWAY: 172.25.100.1 IP6.ADDRESS[1]: fe80::5a5b:2cc3:a448:e2e1/64 IP6.GATEWAY:
6 Modify connection settings
(1) Modify test2 to automatically start
[root@centos73 ~]# nmcli connection modify test2 connection.autoconnect yes
(2) Modify DNS Add DNS 114.114.114.114
[root@centos73 ~]# nmcli connection modify test2 ipv4.dns 172.25.1.1
[root@centos73 ~]# nmcli connection modify test2 +ipv4.dns 114.114.114.114
[root@centos73 ~]# cat /etc/sysconfig/network-scripts/ifcfg-test2 TYPE=Ethernet [……] NAME=test2 UUID=98385bf5-8cc3-47e3-a5f2-51e2d736be6d DEVICE=ens33 ONBOOT=yes DNS1=172.25.1.1 IPADDR=172.25.100.100 PREFIX=24 GATEWAY=172.25.100.1 DNS2=114.114.114.114
(4) Delete DNS
[root@centos73 ~]# nmcli connection modify test2 -ipv4.dns 114.114.114.114
(5) Modify IP address
[root@centos73 ~]# nmcli connection modify test2 ipv4.addresses 200.100.100.100/24 gw4 200.100.100.1
(6)还可以添加多个IP
[root@centos73 ~]# nmcli connection modify test2 +ipv4.addresses 10.10.10.10/8
7 nmcli 命令和/etc/sysconfig/network-scripts/ifcfg-*文件的对应关系
ipv4.method manual BOOTPROTO=none
ipv4.method auto BOOTPROTO=dhcp
ipv4.addresses "192.0.2.1/24 IPADDR=192.0.2.1
PREFIX=24
gw4 192.0.2.254" GATEWAY=192.0.2.254
ipv4.dns 8.8.8.8 DNS0=8.8.8.8
ipv4.dns-search example.com DOMAIN=example.com
ipv4.ignore-auto-dns true PEERDNS=no
connection.autoconnect yes ONBOOT=yes
connection.id eth0 NAME=eth0
connection.interface-name eth0 DEVICE=eth0
802-3-ethernet.mac-address . . . HWADDR= . . .
The above is the detailed content of Network configuration of nmcli. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



If you're suddenly experiencing a slow internet connection on Windows 11 and you've tried every trick in the book, it might have nothing to do with your network and everything to do with your maximum transmission unit (MTU). Problems may occur if your system sends or receives data with the wrong MTU size. In this post, we will learn how to change MTU size on Windows 11 for smooth and uninterrupted internet connection. What is the default MTU size in Windows 11? The default MTU size in Windows 11 is 1500, which is the maximum allowed. MTU stands for maximum transmission unit. This is the maximum packet size that can be sent or received on the network. every support network
![WLAN expansion module has stopped [fix]](https://img.php.cn/upload/article/000/465/014/170832352052603.gif?x-oss-process=image/resize,m_fill,h_207,w_330)
If there is a problem with the WLAN expansion module on your Windows computer, it may cause you to be disconnected from the Internet. This situation is often frustrating, but fortunately, this article provides some simple suggestions that can help you solve this problem and get your wireless connection working properly again. Fix WLAN Extensibility Module Has Stopped If the WLAN Extensibility Module has stopped working on your Windows computer, follow these suggestions to fix it: Run the Network and Internet Troubleshooter to disable and re-enable wireless network connections Restart the WLAN Autoconfiguration Service Modify Power Options Modify Advanced Power Settings Reinstall Network Adapter Driver Run Some Network Commands Now, let’s look at it in detail

We need to use the correct DNS when connecting to the Internet to access the Internet. In the same way, if we use the wrong dns settings, it will prompt a dns server error. At this time, we can try to solve the problem by selecting to automatically obtain dns in the network settings. Let’s take a look at the specific solutions. How to solve win11 network dns server error. Method 1: Reset DNS 1. First, click Start in the taskbar to enter, find and click the "Settings" icon button. 2. Then click the "Network & Internet" option command in the left column. 3. Then find the "Ethernet" option on the right and click to enter. 4. After that, click "Edit" in the DNS server assignment, and finally set DNS to "Automatic (D

What is the "Network error download failed" issue? Before we delve into the solutions, let’s first understand what the “Network Error Download Failed” issue means. This error usually occurs when the network connection is interrupted during downloading. It can happen due to various reasons such as weak internet connection, network congestion or server issues. When this error occurs, the download will stop and an error message will be displayed. How to fix failed download with network error? Facing “Network Error Download Failed” can become a hindrance while accessing or downloading necessary files. Whether you are using browsers like Chrome or platforms like Google Drive and Google Photos, this error will pop up causing inconvenience. Below are points to help you navigate and resolve this issue

If WDMyCloud is not showing up on the network in Windows 11, this can be a big problem, especially if you store backups or other important files in it. This can be a big problem for users who frequently need to access network storage, so in today's guide, we'll show you how to fix this problem permanently. Why doesn't WDMyCloud show up on Windows 11 network? Your MyCloud device, network adapter, or internet connection is not configured correctly. The SMB function is not installed on the computer. A temporary glitch in Winsock can sometimes cause this problem. What should I do if my cloud doesn't show up on the network? Before we start fixing the problem, you can perform some preliminary checks:

This article will introduce the solution to the problem that the globe symbol is displayed on the Win10 system network but cannot access the Internet. The article will provide detailed steps to help readers solve the problem of Win10 network showing that the earth cannot access the Internet. Method 1: Restart directly. First check whether the network cable is not plugged in properly and whether the broadband is in arrears. The router or optical modem may be stuck. In this case, you need to restart the router or optical modem. If there are no important things being done on the computer, you can restart the computer directly. Most minor problems can be quickly solved by restarting the computer. If it is determined that the broadband is not in arrears and the network is normal, that is another matter. Method 2: 1. Press the [Win] key, or click [Start Menu] in the lower left corner. In the menu item that opens, click the gear icon above the power button. This is [Settings].

Wake on LAN is a network feature on Windows 11 that allows you to remotely wake your computer from hibernation or sleep mode. While casual users don't use it often, this feature is useful for network administrators and power users using wired networks, and today we'll show you how to set it up. How do I know if my computer supports Wake on LAN? To use this feature, your computer needs the following: The PC needs to be connected to an ATX power supply so that you can wake it from sleep mode remotely. Access control lists need to be created and added to all routers in the network. The network card needs to support the wake-up-on-LAN function. For this feature to work, both computers need to be on the same network. Although most Ethernet adapters use

In order to make sure your network connection is working properly or to fix the problem, sometimes you need to check the network connection details on Windows 11. By doing this, you can view a variety of information including your IP address, MAC address, link speed, driver version, and more, and in this guide, we'll show you how to do that. How to find network connection details on Windows 11? 1. Use the "Settings" app and press the + key to open Windows Settings. WindowsI Next, navigate to Network & Internet in the left pane and select your network type. In our case, this is Ethernet. If you are using a wireless network, select a Wi-Fi network instead. At the bottom of the screen you should see
