diff options
author | Maxim Devaev <[email protected]> | 2023-12-02 15:02:13 +0200 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2023-12-02 15:02:13 +0200 |
commit | 83d24169f56ca36d91c82374abbd17f1d54b84fb (patch) | |
tree | ce386fb22793b0cc2874bd59ccf478f44a7ef934 | |
parent | 968fb41884a00a2765b6e91cfa2cf9c231b1a427 (diff) |
kvmd-bootconfig: fixed route metrics between eth0/wlan0
-rwxr-xr-x | scripts/kvmd-bootconfig | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/scripts/kvmd-bootconfig b/scripts/kvmd-bootconfig index d275e490..03e20a2d 100755 --- a/scripts/kvmd-bootconfig +++ b/scripts/kvmd-bootconfig @@ -130,6 +130,7 @@ fi make_dhcp_iface() { local _iface="$1" + local _metric="$2" cat <<end_of_file > "/etc/systemd/network/$_iface.network" [Match] Name=$_iface @@ -142,7 +143,7 @@ DNSSEC=no # Use same IP by forcing to use MAC address for clientID ClientIdentifier=mac # https://github.com/pikvm/pikvm/issues/583 -RouteMetric=10 +RouteMetric=$_metric end_of_file } @@ -151,6 +152,7 @@ make_static_iface() { local _addr="$2" local _gw="$3" local _dns="$4" + local _metric="$5" cat <<end_of_file > "/etc/systemd/network/$_iface.network" [Match] Name=$_iface @@ -162,19 +164,21 @@ DNSSEC=no [Route] Gateway=$_gw +# https://github.com/pikvm/pikvm/issues/583 +Metric=$_metric end_of_file } # If the ETH_DHCP is defined, configure eth0 for DHCP if [ -n "$ETH_DHCP" ]; then ETH_IFACE="${ETH_IFACE:-eth0}" - make_dhcp_iface "$ETH_IFACE" + make_dhcp_iface "$ETH_IFACE" 10 fi # If the ETH_ADDR is defined, configure a static address on eth0 if [ -n "$ETH_ADDR" ]; then ETH_IFACE="${ETH_IFACE:-eth0}" - make_static_iface "$ETH_IFACE" "$ETH_ADDR" "$ETH_GW" "$ETH_DNS" + make_static_iface "$ETH_IFACE" "$ETH_ADDR" "$ETH_GW" "$ETH_DNS" 10 fi @@ -192,9 +196,9 @@ fi if [ -n "$WIFI_ESSID" ]; then WIFI_IFACE="${WIFI_IFACE:-wlan0}" if [ -n "$WIFI_ADDR" ]; then - make_static_iface "$WIFI_IFACE" "$WIFI_ADDR" "$WIFI_GW" "$WIFI_DNS" + make_static_iface "$WIFI_IFACE" "$WIFI_ADDR" "$WIFI_GW" "$WIFI_DNS" 50 else - make_dhcp_iface "$WIFI_IFACE" + make_dhcp_iface "$WIFI_IFACE" 50 fi wpa_passphrase "$WIFI_ESSID" "$WIFI_PASSWD" > "/etc/wpa_supplicant/wpa_supplicant-$WIFI_IFACE.conf" chmod 640 "/etc/wpa_supplicant/wpa_supplicant-$WIFI_IFACE.conf" |