{"id":6690,"date":"2019-12-02T23:20:58","date_gmt":"2019-12-02T22:20:58","guid":{"rendered":"https:\/\/michlstechblog.info\/blog\/?p=6690"},"modified":"2019-12-03T07:59:28","modified_gmt":"2019-12-03T06:59:28","slug":"linux-networkmanager-command-line-examples","status":"publish","type":"post","link":"https:\/\/michlstechblog.info\/blog\/linux-networkmanager-command-line-examples\/","title":{"rendered":"Linux NetworkManager: Command line examples"},"content":{"rendered":"<div class=\"twoclick_social_bookmarks_post_6690 social_share_privacy clearfix 1.6.4 locale-en_US sprite-en_US\"><\/div><div class=\"twoclick-js\"><script type=\"text\/javascript\">\/* <![CDATA[ *\/\njQuery(document).ready(function($){if($('.twoclick_social_bookmarks_post_6690')){$('.twoclick_social_bookmarks_post_6690').socialSharePrivacy({\"services\":{\"flattr\":{\"uid\":\"Michl\",\"status\":\"on\",\"the_title\":\"Linux%20NetworkManager%3A%20Command%20line%20examples\",\"the_excerpt\":\"Hi%2C%0D%0A%0D%0Athis%20post%20contains%20some%20NetworkManager%20nmcli%20command%20line%20examples%20for%20frequently%20used%20tasks.%0D%0A%0D%0A%0D%0A%0D%0A%20%28more%26hellip%3B%29\",\"txt_info\":\"2 clicks for more data protection:\\r\\n\\r\\nOnly when you click here, the button will be come active and you can send your recommendation to Flattr. When activating, data are transmitted to third parties. \",\"perma_option\":\"off\"}},\"txt_help\":\"When you activate these fields by clicking, information to Flattr may be transferred abroad, and probably may also stored there.\",\"settings_perma\":\"Enable permanently and accept data transmission. \",\"info_link\":\"http:\\\/\\\/www.heise.de\\\/ct\\\/artikel\\\/2-Klicks-fuer-mehr-Datenschutz-1333879.html\",\"uri\":\"https:\\\/\\\/michlstechblog.info\\\/blog\\\/linux-networkmanager-command-line-examples\\\/\",\"post_id\":6690,\"post_title_referrer_track\":\"Linux+NetworkManager%3A+Command+line+examples\",\"display_infobox\":\"on\"});}});\n\/* ]]> *\/<\/script><\/div><p>Hi,<\/p>\n<p>this post contains some NetworkManager nmcli command line examples for frequently used tasks.<br \/>\n<!-- https:\/\/wiki.ubuntuusers.de\/NetworkManager\/NetworkManager_ohne_GUI\/ --><br \/>\n<!-- https:\/\/docs.fedoraproject.org\/en-US\/Fedora\/25\/html\/Networking_Guide\/sec-Connecting_to_a_Network_Using_nmcli.html --><br \/>\n<!--https:\/\/www.linuxtechi.com\/configure-static-ip-address-rhel8\/--><br \/>\n<!--more--><\/p>\n<p>Show devices<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@debdev ~# nmcli dev status\r\n<\/pre>\n<p>Show all connections<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@debdev ~# nmcli connection show\r\n<\/pre>\n<p>Add a new connection with DHCP enabled<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@debdev ~# nmcli connection add type ethernet ifname eth0 \r\n<\/pre>\n<p>Change Connection name\/id<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@debdev ~# nmcli connection modify &quot;Wired connection 2&quot; connection.id &quot;ethernet 2&quot;\r\n<\/pre>\n<p>Static IP Address<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@debdev ~# nmcli con add con-name &quot;ethernet 2&quot; ifname eth0 type ethernet ip4 10.254.10.10\/24 gw4 10.254.10.254\r\n<\/pre>\n<p>Set DNS<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@debdev ~# nmcli con mod &quot;ethernet 2&quot; ipv4.dns &quot;10.254.10.252 10.254.10.253&quot;\r\n<\/pre>\n<p>Add DNS<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@debdev ~# nmcli con mod &quot;ethernet 2&quot; +ipv4.dns 10.254.10.252\r\n<\/pre>\n<p>Add a static route<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@debdev ~# nmcli con mod &quot;ethernet 3&quot; +ipv4.routes &quot;192.168.122.0\/24 10.10.11.254&quot;\r\n<\/pre>\n<p>Change a static IP <\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@debdev ~# nmcli con mod &quot;ethernet 2&quot; ipv4.addresses 10.254.10.11\/24\r\n<\/pre>\n<p>Add a  second static IP to an interface<br \/>\nConnection set up<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@debdev ~# nmcli con up &quot;ethernet 2&quot; ip4 10.254.10.12\/24\r\n<\/pre>\n<p>Switch from static IP to DHCP<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@debdev ~#  nmcli con mod &quot;ethernet 2&quot; ipv4.method auto\r\n<\/pre>\n<p>Connection set up<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@debdev ~# nmcli con up &quot;ethernet 2&quot; ifname eth0\r\n<\/pre>\n<p>Delete a connection<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@debdev ~# nmcli con delete con-name &quot;eth IoT&quot;\r\n<\/pre>\n<p>WiFi<br \/>\nList alle WLAN&#8217;s<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@debdev ~# nmcli device wifi list\r\n<\/pre>\n<p>Network Manager as WiFi Access Point with SSID MyHomeWiFi, WPA2 authentication and &#8220;My Secret WiFi Password 999!&#8221; as PreSharedkey<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@debdev ~# nmcli connection add type wifi ifname wlan0 con-name &quot;MyAccessPoint-Home&quot; autoconnect no ssid &quot;MyHomeWiFi&quot;\r\nroot@debdev ~# nmcli connection modify &quot;MyAccessPoint-Home&quot; 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared\r\nroot@debdev ~# nmcli connection modify &quot;MyAccessPoint-Home&quot; wifi-sec.key-mgmt wpa-psk\r\nroot@debdev ~# nmcli connection modify &quot;MyAccessPoint-Home&quot; wifi-sec.psk &quot;My Secret WiFi Password 999!&quot;\r\nroot@debdev ~# nmcli connection modify &quot;MyAccessPoint-Home&quot; ipv4.addresses &quot;10.11.1.1\/24&quot;\r\nroot@debdev ~# nmcli connection modify &quot;MyAccessPoint-Home&quot; ipv4.method manual\r\nroot@debdev ~# nmcli connection modify &quot;MyAccessPoint-Home&quot; autoconnect yes\r\nroot@debdev ~# nmcli connection up &quot;MyAccessPoint-Home&quot;\r\n<\/pre>\n<p>Michael<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, this post contains some NetworkManager nmcli command line examples for frequently used tasks.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[870,3],"tags":[1392,1393,224,1391,1005],"class_list":["post-6690","post","type-post","status-publish","format-standard","hentry","category-debian","category-linux","tag-command-line-examples","tag-create-access-point","tag-linux-2","tag-nmcli","tag-wifi"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/6690","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/comments?post=6690"}],"version-history":[{"count":10,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/6690\/revisions"}],"predecessor-version":[{"id":6708,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/6690\/revisions\/6708"}],"wp:attachment":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/media?parent=6690"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/categories?post=6690"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/tags?post=6690"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}