🖥️nmcli

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the nmcli command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███╗   ██╗███╗   ███╗ ██████╗██╗     ██╗
#                ████╗  ██║████╗ ████║██╔════╝██║     ██║
#                ██╔██╗ ██║██╔████╔██║██║     ██║     ██║
#                ██║╚██╗██║██║╚██╔╝██║██║     ██║     ██║
#                ██║ ╚████║██║ ╚═╝ ██║╚██████╗███████╗██║
#                ╚═╝  ╚═══╝╚═╝     ╚═╝ ╚═════╝╚══════╝╚═╝
                                                        
                                                        
                                                       
# Desc: Command line interface to NetworkManager

# Connect to a wireless access point - Parameters:
# 	<wiface> -- the name of your wireless interface
#	<ssid> -- the SSID of the access point
#	<pass> -- the WiFi password
nmcli d wifi connect <ssid> password <pass> iface <wiface>

# Disconnect from WiFi - Parameters:
#	<wiface> -- the name of your wireless interface
nmcli d wifi disconnect iface <wiface>

# Get WiFi status (enabled / disabled)
nmcli radio wifi

# Enable / Disable WiFi
nmcli radio wifi <on|off>

# Show all available WiFi access points
nmcli dev wifi list

# Refresh the available WiFi connection list
nmcli dev wifi rescan

# Show all available connections
nmcli con

# Show only active connections
nmcli con show --active

# Review the available devices
nmcli dev status

# Add a dynamic ethernet connection - parameters:
#	<name> -- the name of the connection
#	<iface_name> -- the name of the interface
ncmli con add type ethernet con-name <name> ifname <iface_name>

# Bring up the ethernet connection
nmcli con up <name>

################################

# connection profiles. We find them in /etc/sysconfig/network-scripts directory.
# ifcfg-static1  und ifcfg-Myoffice1

# We realize that some properties have different values and some others don’t exist if it isn’t necessary. Let’s have a quick look to most important of them.
#    TYPE, we have ethernet type here. We could have wifi, team, bond and others.
#    DEVICE, the name of the network device which is associated with this profile.
#    BOOTPROTO, if it has value “dhcp” then our connection profile takes dynamic IP from dhcp server, if it has value “none” then it takes no dynamic IP and probably whe assign a static IP.
#    IPADDR, is the static IP we assign to our profile.
#    PREFIX, the subnet mask. A value of 24 means 255.255.255.0. You can understand better the subnet mask if you write down its binary format. For example values of 16, 24, 26 means that the first 16, 24 or 26 bits respectively are 1 and the rest 0, defining exactly what the network address is and what is the range of ip which can be assigned.
#    GATEWAY, the gateway IP.
#    DNS1, DNS2, two dns servers we want to use.
#    ONBOOT, if it has value “yes” it means, that on boot our computer will read this profile and try to assign it to its device.
  
 
nmcli con show -a
# check our connections - equal command: nmcli connection show - nmcli con show - nmcli c s 

ip a
# ip addr off devices

nmcli con add type ethernet con-name dhcp1 ifname eth0
# We can make our first connection profile. The minimum properties we must define are type, ifname and con-name:
#    type – for the type of connection.
#    ifname – for the device name which is assigned our connection.
#    con-name – for the connection name.

    
    
    
nmcli con add type ethernet con-name static2 ifname enp0s3 ip4 192.168.1.50/24 gw4 192.168.1.1
# Let us make a new Ethernet connection profile with name static2, which will be assigned to device enp0s3, with static IP 192.168.1.50, subnet mask 255.255.255.0=24 and gateway 192.168.1.1.

nmcli con mod static2 ipv4.dns "8.8.8.8 8.8.4.4"
# Let us modify the last connection profile and add two dns servers.

nmcli con down static1 ; nmcli con up static2
# Now let us bring up this connection profil

nmcli con mod static2 connection.autoconnect no
# If you do not want your connection profile to autoconnect

nmcli con mod static2 connection.permissions otto
# We let only user otto to use this profile

nmcli con mod static2 connection.permissions user:otto,john
# If you want to give permissions to more than one users, you must type user:user1,user2 without blank space between them

nmcli device wifi list
# Show a prettified list of nearby wireless APs

#==============================##==============================#
# CMD NMCLI						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░