{"id":3153,"date":"2024-01-11T11:25:22","date_gmt":"2024-01-11T11:25:22","guid":{"rendered":"https:\/\/blog.designed79.co.uk\/?p=3153"},"modified":"2024-09-11T12:38:23","modified_gmt":"2024-09-11T12:38:23","slug":"how-to-set-network-metric-with-networkmanager","status":"publish","type":"post","link":"https:\/\/blog.designed79.co.uk\/?p=3153","title":{"rendered":"How to set network metric with NetworkManager"},"content":{"rendered":"\n<p>Sometimes we want to have several connections at the same time, one to the ethernet (wired lan) and one other to the wireless router, with two different gateways. In this documentation i describe how to make wireless connection prior to ethernet connection in each linux OS using NetworkManager service to moderate network connections. I&#8217;ve tested these instruction in fedora 31 already.<\/p>\n\n\n\n<p><strong>List Your Connections<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">% nmcli connection <br> NAME        UUID                                  TYPE      DEVICE               <br> sample1     a16d1a96-2833-4876-a6c2-************  vpn       wlp0s20f0u11 <br> bevaght     f46ba9ff-1114-4e79-9c8a-************  wifi      wlp0s20f0u11<br> eth1        7648e3eb-c03f-46e9-b24e-************  ethernet  enp2s0<\/pre>\n\n\n\n<p><strong>Edit the wireless connection<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ nmcli connection edit bevaght\n\n===| nmcli interactive connection editor |===\n\nEditing existing '802-11-wireless' connection: 'bevaght'\n\nType 'help' or '?' for available commands.\nType 'print' to show all the connection properties.\nType 'describe [&lt;setting&gt;.&lt;prop&gt;]' for detailed property description.\n\nYou may edit the following settings: connection, 802-11-wireless (wifi), 802-11-wireless-security (wifi-sec), 802-1x, ethtool, match, ipv4, ipv6, tc, proxy\nnmcli&gt; set ipv4.route-metric 10\nnmcli&gt; save\nnmcli&gt; quit<\/pre>\n\n\n\n<p><strong>Edit the ethernet connection<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ nmcli connection edit eth1<br><br>===| nmcli interactive connection editor |===<br><br>Editing existing '802-3-ethernet' connection: 'eth1'<br><br>Type 'help' or '?' for available commands.<br>Type 'print' to show all the connection properties.<br>Type 'describe [&lt;setting>.&lt;prop>]' for detailed property description.<br><br>You may edit the following settings: connection, 802-3-ethernet (ethernet), 802-1x, dcb, sriov, ethtool, match, ipv4, ipv6, tc, proxy<br>nmcli> set ipv4.route-metric 2000<br>nmcli> save<br>nmcli> quit<br><\/pre>\n\n\n\n<p><a href=\"https:\/\/dev.to\/emamirazavi\/how-to-set-metric-in-networkmanager-system-4525#restart-networkmanager-service\"><\/a><strong>Restart NetworkManager service<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\">\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">$ sudo systemctl restart NetworkManager<\/div><\/div>\n\n<\/pre>\n\n\n\n<p><strong>Congratulation! routes related to the WiFi connection named\u00a0bevaght are prior to routes related to the Ethernet connection named\u00a0eth1<\/strong><\/p>\n\n\n\n<p>$ route -n<br>Kernel IP routing table<br>Destination     Gateway         Genmask         Flags Metric Ref    Use Iface<br>0.0.0.0         192.168.0.1     0.0.0.0         UG    10     0        0 wlp0s20f0u11<br>0.0.0.0         192.168.1.1     0.0.0.0         UG    2000   0        0 enp2s0<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes we want to have several connections at the same time, one to the ethernet (wired lan) and one other to the [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3153","post","type-post","status-publish","format-standard","hentry","category-info-on-tech"],"_links":{"self":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3153","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3153"}],"version-history":[{"count":10,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3153\/revisions"}],"predecessor-version":[{"id":3185,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3153\/revisions\/3185"}],"wp:attachment":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}