Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Nmcli Network Management Command Line tool Foundation

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Introduction

In this tutorial, we will discuss the network management command line tool NetworkManager command line tool, also known as nmcli, in CentOS / RHEL 7. Those who use ifconfig should avoid using ifconfig in CentOS 7.

Let's configure some network settings with the nmcli tool.

To get the address information of all interfaces in the system

[root@localhost ~] # ip addrshow

Sample output:

1: lo: mtu 65536 qdisc noqueue state UNKNOWN

Link/loopback 00:00:00:00:00:00 brd00:00:00:00:00:00

Inet 127.0.0.1/8 scope host lo

Valid_lft forever preferred_lft forever

Inet6:: 1/128 scope host

Valid_lft forever preferred_lft forever

2: eno16777736: mtu 1500 qdisc pfifo_fast state UP qlen 1000

Link/ether 00:0c:29:67:2f:4c brdff:ff:ff:ff:ff:ff

Inet 192.168.1.51/24 brd 192.168.1.255 scopeglobal eno16777736

Valid_lft forever preferred_lft forever

Inet6 fe80::20c:29ff:fe67:2f4c/64 scope link

Valid_lft forever preferred_lft forever

Retrieve packet statistics related to connected interfaces

[root@localhost ~] # ip-slink show eno16777736

Get the routing configuration

[root@localhost ~] # ip route

Sample output:

Default via 192.168.1.1 deveno16777736 proto static metric 100

192.168.1.0/24 deveno16777736 proto kernel scope link src 192.168.1.51 metric 100

Analyze the host / website path

[root@localhost ~] # tracepathunixmen.com

The output is like traceroute, but more complete.

Nmcli tool

Nmcli is a very rich and flexible command line tool. Nmcli is used in the following situations:

Device-Network interface in use

Connection-A set of configuration settings that can have multiple connections for a single device and can switch between connections.

Find out how many connections serve how many devices

[root@localhost ~] # nmcliconnection show

Get details of a specific connection

[root@localhost ~] # nmcliconnection show eno1

Get the status of the network device

[root@localhost ~] # nmclidevice status

DEVICE TYPE STATE CONNECTION

Eno16777736 ethernet connected eno1

Lo loopback unmanaged--

Use "dhcp" to create a new connection

[root@localhost ~] # nmcliconnection add con-name "dhcp" type ethernet ifname eno16777736

Here,

Connection add-add a new connection

Con-name-connection name

Type-device typ

Ifname-Interface name

This command adds a connection using the dhcp protocol

Sample output:

Connection 'dhcp' (163a6822-cd50-4d23-bb42-8b774aeab9cb) successfully added.

Do not assign IP through dhcp, use "static" to add address

[root@localhost ~] # nmcliconnection add con-name "static" ifname eno16777736 autoconnect notype ethernet ip4 192.168.1.240 gw4 192.168.1.1

Sample output:

Connection 'static' (8e69d847-03d7-47c7-8623-bb112f5cc842) successfully added.

Update the connection:

[root@localhost ~] # nmcliconnection up eno1

Check again to see if the ip address has changed

[root@localhost ~] # ip addrshow

Add DNS settings to the static connection

[root@localhost ~] # nmcliconnection modify "static" ipv4.dns 202.131.124.4

Add more DNS

[root@localhost ~] # nmcliconnection modify "static" + ipv4.dns 8.8.8.8

Note: use the extra + symbol, and if + ipv4.dns, not ip4.dns.

Add an additional ip address

[root@localhost ~] # nmcliconnection modify "static" + ipv4.addresses 192.168.200.1Univer 24

Use the command to refresh the settings:

[root@localhost ~] # nmcliconnection up eno1

As you can see, the settings are in effect.

It's over.

Free access to Brother Company IT Education original linux Operation and maintenance engineer Video / detailed linux tutorial, consult the official website customer service: http://www.lampbrother.net/linux/

Or hook up with Q2430675018

Welcome to linux communication group 478068715.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report