From 727e2a1d9dfa66bdc4a5042f09c80f910c11f7b9 Mon Sep 17 00:00:00 2001 From: Denis Silakov Date: Fri, 13 Jan 2017 18:44:40 +0300 Subject: [PATCH] Make gateway processing POSIX-compliant --- modules.d/40network/dhclient-script.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules.d/40network/dhclient-script.sh b/modules.d/40network/dhclient-script.sh index 2ad04f6be..3d9af99f2 100755 --- a/modules.d/40network/dhclient-script.sh +++ b/modules.d/40network/dhclient-script.sh @@ -48,13 +48,16 @@ setup_interface() { # point-to-point connection => set explicit route to gateway echo ip route add $gw dev $netif > /tmp/net.$netif.gw fi - IFS=' ' read -r main_gw other_gw <<< "$gw" - echo ip route replace default via $main_gw dev $netif >> /tmp/net.$netif.gw - if [ -n "$other_gw" ] ; then - for g in $other_gw; do - echo ip route add default via $g dev $netif >> /tmp/net.$netif.gw - done - fi + + echo "$gw" | { + IFS=' ' read -r main_gw other_gw + echo ip route replace default via $main_gw dev $netif >> /tmp/net.$netif.gw + if [ -n "$other_gw" ] ; then + for g in $other_gw; do + echo ip route add default via $g dev $netif >> /tmp/net.$netif.gw + done + fi + } fi if getargbool 1 rd.peerdns; then -- 2.47.2