Change in osmo-dev[master]: net/templates/ tweak masquerade

osmith gerrit-no-reply at
Mon Jul 12 08:35:49 UTC 2021

osmith has submitted this change. ( )

Change subject: net/templates/ tweak masquerade

net/templates/ tweak masquerade

Replace the old check with an exact check for the given rule. The old
check doesn't work on my system if docker is running and sets up other
masquerading rules.

Change -A to -I, so it is less likely to be affected by whatever other
rules may already be above in the chain.

Change-Id: I30c22fe4e7683611e8dada329dbf7d51f78b6016
M net/templates/
1 file changed, 3 insertions(+), 2 deletions(-)

  laforge: Looks good to me, but someone else must approve; Verified
  pespin: Looks good to me, but someone else must approve
  osmith: Looks good to me, approved; Verified

diff --git a/net/templates/ b/net/templates/
index 0eacb0f..8571a42 100755
--- a/net/templates/
+++ b/net/templates/
@@ -13,8 +13,9 @@
 sudo true || exit 1
-if [ -z "$(sudo iptables -L -t nat | grep MASQUERADE)" ]; then
-  sudo iptables -t nat -A POSTROUTING -s ${GGSN_NET} -o $dev -j MASQUERADE
+if ! sudo iptables -t nat -C POSTROUTING -s ${GGSN_NET} -o $dev -j MASQUERADE 2>/dev/null; then
+  echo "Adding iptables rule for masquerade"
+  sudo iptables -t nat -I POSTROUTING -s ${GGSN_NET} -o $dev -j MASQUERADE
 if [ "$(sudo cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then

To view, visit
To unsubscribe, or for help writing mail filters, visit

Gerrit-Project: osmo-dev
Gerrit-Branch: master
Gerrit-Change-Id: I30c22fe4e7683611e8dada329dbf7d51f78b6016
Gerrit-Change-Number: 24875
Gerrit-PatchSet: 3
Gerrit-Owner: osmith <osmith at>
Gerrit-Reviewer: laforge <laforge at>
Gerrit-Reviewer: neels <nhofmeyr at>
Gerrit-Reviewer: osmith <osmith at>
Gerrit-Reviewer: pespin <pespin at>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the gerrit-log mailing list