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

osmith gerrit-no-reply at lists.osmocom.org
Mon Jul 12 08:35:49 UTC 2021


osmith has submitted this change. ( https://gerrit.osmocom.org/c/osmo-dev/+/24875 )

Change subject: net/templates/run.sh: tweak masquerade
......................................................................

net/templates/run.sh: 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/run.sh
1 file changed, 3 insertions(+), 2 deletions(-)

Approvals:
  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/run.sh b/net/templates/run.sh
index 0eacb0f..8571a42 100755
--- a/net/templates/run.sh
+++ b/net/templates/run.sh
@@ -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
 fi
 
 if [ "$(sudo cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-dev/+/24875
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-dev
Gerrit-Branch: master
Gerrit-Change-Id: I30c22fe4e7683611e8dada329dbf7d51f78b6016
Gerrit-Change-Number: 24875
Gerrit-PatchSet: 3
Gerrit-Owner: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210712/a651c92f/attachment.htm>


More information about the gerrit-log mailing list