Networkmanager nmcli

From wikinotes
Revision as of 21:59, 19 June 2021 by Will (talk | contribs) (→‎DNS)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Manages several network types.
You may also be interested in netctl.

Documentation

homepage https://wiki.gnome.org/Projects/NetworkManager
official docs https://developer.gnome.org/NetworkManager/stable/

Install

sudo pacman -S networkmanager

sudo systemctl enable NetworkManager.service
sudo systemctl start NetworkManager.service

Basics

nmcli con[nection]                 # list connections
nmcli dev[ice]                     # list network interfaces
nmcli con[nection] edit ${NAME}    # configure connection
nmcli con[nection] up/down ${NAME} # set connection up/down

Network Types

Wired

Wired connections are automatically detected and configured as DHCP.
Alternatively, you can adjust them as you'd like.

# create a connection-profile on 'em0' with static-ip
nmcli con[nection] add \
  con-name home-network    `# name connection` \
  ifname em0 \
  type ethernet \
  ip4 192.168.100.100/24   `# static-ip` \
  gw4 192.168.100.1        `# gateway`

Wireless

# list network APs (SSIDs)
nmcli device wifi list

# configure wireless connection
nmcli device wifi \
  connect ${SSID} \
  password ${PASSWORD} \
  hidden yes  `# only if SSID is hidden`

# disable wifi
nmcli radio wifi off

Bluetooth

todo

Bridge

todo

Modem

todo

Configuring Connections

nmcli con[nection]                                 # list all connections
nmcli con[nection] edit ${NAME}                    # connection editor interpreter
nmcli con[nection] mod ${NAME} ${OPTION} ${VALUE}  # edit on cli
print  # show all options

DNS

nmcli con mod <connectionName> ipv4.dns "208.67.222.222 208.67.220.220"  # set DNS addresses
nmcli con mod <connectionName> ipv4.ignore-auto-dns yes                  # ignore DHCP provided nameservers