fix parsing ip on more kinds of networks
authorIan Kelling <ian@iankelling.org>
Thu, 30 Mar 2017 23:31:00 +0000 (16:31 -0700)
committerIan Kelling <ian@iankelling.org>
Thu, 30 Mar 2017 23:31:00 +0000 (16:31 -0700)
newns

diff --git a/newns b/newns
index d4ee334ac784232c291548307c65f25166ad4c76..823d184b5b07b323d17acbe91a46b5b2a3ccd694 100755 (executable)
--- a/newns
+++ b/newns
@@ -157,7 +157,7 @@ dexec() { ip netns exec default "$@"; }
 
 # background: head -n1 is defensive. Not sure if there is some weird feature
 # for 2 routes to be 0/0.
 
 # background: head -n1 is defensive. Not sure if there is some weird feature
 # for 2 routes to be 0/0.
-gateway_if=$(ipd route list exact 0/0 | head -n1| sed -r 's/.*\s(\S+)\s*$/\1/')
+gateway_if=$(ipd route list exact 0/0 | head -n1| sed -r 's/.*dev\s+(\S+).*/\1/')
 nat() { dexec iptables -t nat $1 POSTROUTING -o $gateway_if -j MASQUERADE \
               -m comment --comment "systemd network namespace nat"; }
 
 nat() { dexec iptables -t nat $1 POSTROUTING -o $gateway_if -j MASQUERADE \
               -m comment --comment "systemd network namespace nat"; }