Skip to content

Commit 66acf2f

Browse files
committed
use inserts instead of append
1 parent f2087b2 commit 66acf2f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

netns.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,25 +223,25 @@ _exec_in_netns("ip link set", _vecId, "up")
223223
_exec_in_netns("ip route add default via", _vehIp)
224224

225225
if not _safe_exec("iptables -C FORWARD -s", _vecIp .. "/30", "-j ACCEPT") then
226-
_exec("iptables -A FORWARD -s", _vecIp .. "/30", "-j ACCEPT")
226+
_exec("iptables -I FORWARD -s", _vecIp .. "/30", "-j ACCEPT")
227227
end
228228
if not _safe_exec("iptables -C FORWARD -d", _vecIp .. "/30", "-j ACCEPT") then
229-
_exec("iptables -A FORWARD -d", _vecIp .. "/30", "-j ACCEPT")
229+
_exec("iptables -I FORWARD -d", _vecIp .. "/30", "-j ACCEPT")
230230
end
231231

232232
if _options.masquerade then
233233
if not _safe_exec("iptables -t nat -C POSTROUTING -s", _vecIp .. "/30", "-j MASQUERADE") then
234-
_exec("iptables -t nat -A POSTROUTING -s", _vecIp .. "/30", "-j MASQUERADE")
234+
_exec("iptables -t nat -I POSTROUTING -s", _vecIp .. "/30", "-j MASQUERADE")
235235
end
236236
else
237237
if not _safe_exec("iptables -t nat -C POSTROUTING -s", _vecIp .. "/30", "-j SNAT --to-source", _options.outboundAddr) then
238-
_exec("iptables -t nat -A POSTROUTING -s", _vecIp .. "/30", "-j SNAT --to-source", _options.outboundAddr)
238+
_exec("iptables -t nat -I POSTROUTING -s", _vecIp .. "/30", "-j SNAT --to-source", _options.outboundAddr)
239239
end
240240
end
241241

242242
for _, v in ipairs(_options.publish) do
243243
if not _safe_exec("iptables -t nat -C PREROUTING -p", v.proto, "-d", v.hAddr, "--dport", v.hport, "-j DNAT --to-destination", _vecIp .. ":" .. v.cport) then
244-
_exec("iptables -t nat -A PREROUTING -p", v.proto, "-d", v.hAddr, "--dport", v.hport, "-j DNAT --to-destination", _vecIp .. ":" .. v.cport)
244+
_exec("iptables -t nat -I PREROUTING -p", v.proto, "-d", v.hAddr, "--dport", v.hport, "-j DNAT --to-destination", _vecIp .. ":" .. v.cport)
245245
end
246246
end
247247

0 commit comments

Comments
 (0)