Skip to content

Commit 574feb9

Browse files
committed
Also support ports on regular netmasks (not excluding)
1 parent 4ee0516 commit 574feb9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

firewall.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,15 @@ def do_iptables(port, dnsport, subnets):
107107
'--dest', '%s/%s' % (snet,swidth),
108108
'-p', 'tcp')
109109
else:
110-
ipt_ttl('-A', chain, '-j', 'REDIRECT',
110+
if sport > 0:
111+
ipt_ttl('-A', chain, '-j', 'REDIRECT',
112+
'--dest', '%s/%s' % (snet,swidth),
113+
'-m', 'tcp',
114+
'--dport', '%d' % sport,
115+
'-p', 'tcp',
116+
'--to-ports', str(port))
117+
else:
118+
ipt_ttl('-A', chain, '-j', 'REDIRECT',
111119
'--dest', '%s/%s' % (snet,swidth),
112120
'-p', 'tcp',
113121
'--to-ports', str(port))

0 commit comments

Comments
 (0)