Networkmanager nmcli: Difference between revisions

From wikinotes
 
(9 intermediate revisions by the same user not shown)
Line 32: Line 32:
# common commands
# common commands
nmcli d[evice]    # network interfaces
nmcli d[evice]    # network interfaces
nmcli c[onnection] # network connections
nmcli c[onnection] # connection profiles, configuration


# uncommon commands
# uncommon commands
Line 41: Line 41:
cookbook
cookbook
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
nmcli n off                       # disable all networking
# power saving
nmcli all off                     # disable all radio
nmcli n off                   # disable all networking
nmcli c[onnection] edit ${NAME}   # configure connection
nmcli r all off               # disable all radio
nmcli c[onnection] up/down ${NAME} # set connection up/down
 
# connection management
nmcli c edit ${NAME}         # configure connection
nmcli c up/down ${NAME}     # set connection up/down
nmcli c show ${NAME}        # detailed info about connection
 
# device configuration
nmcli d show                # detailed info about devices
nmcli -f all d show ${IFACE} # show full configuration of device
</syntaxhighlight>
</syntaxhighlight>
</blockquote><!-- Usage -->
</blockquote><!-- Usage -->
Line 55: Line 63:
Alternatively, you can adjust them as you'd like.
Alternatively, you can adjust them as you'd like.


<source lang="bash">
 
# create a connection-profile on 'em0' with static-ip
Static IP-address
nmcli con[nection] add \
<syntaxhighlight lang="bash">
   con-name home-network    `# name connection` \
nmcli con add \
   ifname em0 \
   con-name eno1_holocron \
   ifname eno1 \
   type ethernet \
   type ethernet \
   ip4 192.168.100.100/24   `# static-ip` \
   ip4 192.168.1.123/24 `# static-ip` \
   gw4 192.168.100.1       `# gateway`
   gw4 192.168.1.1       `# gateway`
</source>
</syntaxhighlight>
</blockquote><!-- Wired -->
</blockquote><!-- Wired -->


== Wireless ==
== Wireless ==
<blockquote>
<blockquote>
make sure to install dependencies
<source lang="bash">
pacman -S linux-firmware iw wpa_supplicant
</source>
<source lang="bash">
<source lang="bash">
# list network APs (SSIDs)
# list network APs (SSIDs)

Latest revision as of 23:31, 10 March 2024

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

# general commands
nmcli g[eneral]     # status, reload configuration, loglevel
nmcli r[adio]       # enable/disable/status radio connections (wifi, wwan)
nmcli n[etworking]  # enable/disable/status all networking

# common commands
nmcli d[evice]     # network interfaces
nmcli c[onnection] # connection profiles, configuration

# uncommon commands
nmcli a[gent]       # nmcli as polkit/secret agent
nmcli m[onitor]     # observe changes in connectivity, profiles

cookbook

# power saving
nmcli n off                   # disable all networking
nmcli r all off               # disable all radio

# connection management
nmcli c edit ${NAME}         # configure connection
nmcli c up/down ${NAME}      # set connection up/down
nmcli c show ${NAME}         # detailed info about connection

# device configuration
nmcli d show                 # detailed info about devices
nmcli -f all d show ${IFACE} # show full configuration of device

Network Types

Wired

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


Static IP-address

nmcli con add \
  con-name eno1_holocron \
  ifname eno1 \
  type ethernet \
  ip4 192.168.1.123/24  `# static-ip` \
  gw4 192.168.1.1       `# gateway`

Wireless

make sure to install dependencies

pacman -S linux-firmware iw wpa_supplicant
# 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