Nmcli

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 19

nmcli

• nmcli is a command-line tool which is used for controlling


NetworkManager. nmcli command can also be used to display
network device status, create, edit, activate/deactivate, and delete
network connections. Typical Uses: Scripts: Instead of manually
managing the network connections it utilize NetworkManager via
nmcli
How to View Connections using nmcli
How to Check the Device Status using nmcli
To check the device status using nmcli command.

nmcli dev status


• mcli connection add \
• con-name “lpu" \
• ifname "*" \
• type ethernet \
• ipv4.method manual \
• ipv4.addresses "192.168.1.100/24" \
• ipv4.gateway "192.168.1.1" \
• ipv4.dns "8.8.8.8"
• This command displays the current status of all network devices on
your system. It shows whether each device is connected or
disconnected, along with additional information like the device type
and the connection type it is associated with.The output might vary
with different machines
Activating
• ifname "*": This option specifies the network interface name. The
asterisk (*) is a wildcard indicating that any available Ethernet
interface should be used. If you want to specify a specific interface,
you would replace the asterisk with the name of the interface (e.g.,
eth0).
• type ethernet: This option specifies the connection type. In this case,
it's an Ethernet connection.
• ipv4.method manual: This option sets the IPv4 addressing method to
manual configuration, meaning that you'll manually specify the IP
address, subnet mask, gateway, and DNS server(s).
• ipv4.addresses "192.168.1.100/24": This option sets the IPv4 address
and subnet mask for the connection. The address "192.168.1.100" is
the chosen IP address, and "/24" is the CIDR notation for the subnet
mask (which means a subnet mask of 255.255.255.0, indicating a
subnet with 256 IP addresses).
• ipv4.gateway "192.168.1.1": This option specifies the IPv4 gateway
(router) for the connection. "192.168.1.1" is used here as an example,
but you would replace it with the IP address of your actual
gateway/router.
• ipv4.dns "8.8.8.8": This option specifies the IPv4 DNS server for the
connection. "8.8.8.8" is used here as an example, which is one of
Google's public DNS servers. You can replace it with the IP address of
your DNS server(s).
Changing the port
• Edit SSH Configuration File:

• Open the SSH server configuration file using a text editor. Typically,
this file is located at /etc/ssh/sshd_config:

• sudo nano /etc/ssh/sshd_config


• Locate the Port Configuration:

• Within the SSH server configuration file, find the line that specifies the port. It looks like
this:

• bash
• #Port 22
• Remove the # symbol at the beginning of the line (if present) to uncomment it, and then
change 22 to 2223:

• bash
• Port 2223
• Save and Close the File:

• After making the change, save the file and exit the text editor.

• Restart SSH Service:

• To apply the changes, restart the SSH service:

• sudo systemctl restart sshd


• Update Firewall Rules (if applicable):

• If you have a firewall enabled, such as firewalld, you need to allow


traffic on the new SSH port. Run the following command:

• bash
• sudo firewall-cmd --zone=public --add-port=2223/tcp --permanent
• sudo firewall-cmd --reload
• netstat: Command to display network connections, routing tables,
interface statistics, masquerade connections, and multicast
memberships.
• -tuln: Options to display TCP (-t) and UDP (-u) listening sockets,
show numerical addresses (-n) instead of resolving hostnames, and list
listening sockets (-l).
• Verify SSH Port Change:

• You can verify that the SSH server is now listening on port 2223 by
running:

• bash
• sudo netstat -tuln | grep 2223

You might also like