Category: Networking

  • Connection metric management

    Here is how with some simple steps I changed the metric of an internet connection in order to give priority to a usb dongle so its set as the default interface for internet traffic in my personal laptop. The laptop’s integrated wifi interface does not support 5 Ghz connections so every time I boot up the system I had to manually disconnect the integrated interface and reconnect it so its metric changes to a higher value:

    First one needs to see the internet connections managed by the NetworkManager service in order to get the name of the internet connection we need to modify:

    nmcli connection show

    The list shows the 2 wifi connections I currently use. One is for General internet traffic and the other one to manage an openwrt device:

    NAME                    UUID                                  TYPE      DEVICE
    Connection_1            0711f8ae-049e-4e4f-8800-3cffc70b458f  wifi      wlp3s0
    Connection_2            b2c7835e-69ac-4520-b401-f7120a456d65  wifi      wlx3xvre3db545  

    To verify the current metric for both interfaces we use ip route:

    default via 192.168.1.1 dev wlp3s0 proto dhcp src 192.168.1.111 metric 600
    default via 192.168.5.1 dev wlx3xvre3db545 proto dhcp src 192.168.5.198 metric 601  

    As we can see the internet traffic has a default route through the slower wifi interface. We can change this by changing the metric:

    nmcli connection modify "Connection_2" ipv4.route-metric 100

    We restart the service:

    sudo systemctl restart NetworkManager

    Once the service is back up we verify the metric again:

    default via 192.168.5.1 dev wlx3xvre3db545 proto dhcp src 192.168.3.198 metric 100  
    default via 192.168.1.1 dev wlp3s0 proto dhcp src 192.168.1.111 metric 602

    This change will be persistent after a reboot.

  • Wake On Lan

    List the interfaces on your system for proper identification. The ip command will inform the names and states of them.

    ip a

    Execute ethtool with the name of the interface that must be configured to wake on lan.

    sudo ethtool [interface] 

    To enable WOL on an interface (non-persistent) type:

    sudo ethtool -s [interface] wol g

    To make a persistent change in the interface edit the /etc/network/interfaces.d/eth0 (or modify the global interface config file /etc/network/interfaces):

    auto eth0
    iface eth0 inet dhcp
         ethernet-wol g

    OR

    auto eth0
    iface eth0 inet dhcp
         post-up ethtool -s [interface] wol g

    Another way is to edit the main configuration file and add the following instruction at the end of the file:

    post-up /usr/sbin/ethtool -s [interface] wol g

    The post-up command will trigger the execution of the ethtool command on the selected interface after the interface has been initialized.

    etherwake, wakeonlan, gwakeonlan

    Wake-on: g means it is enabled.