Skip to content

Commit

Permalink
Also support ports on regular netmasks (not excluding)
Browse files Browse the repository at this point in the history
  • Loading branch information
vStone committed Nov 12, 2013
1 parent 4ee0516 commit 574feb9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,15 @@ def do_iptables(port, dnsport, subnets):
'--dest', '%s/%s' % (snet,swidth),
'-p', 'tcp')
else:
ipt_ttl('-A', chain, '-j', 'REDIRECT',
if sport > 0:
ipt_ttl('-A', chain, '-j', 'REDIRECT',
'--dest', '%s/%s' % (snet,swidth),
'-m', 'tcp',
'--dport', '%d' % sport,
'-p', 'tcp',
'--to-ports', str(port))
else:
ipt_ttl('-A', chain, '-j', 'REDIRECT',
'--dest', '%s/%s' % (snet,swidth),
'-p', 'tcp',
'--to-ports', str(port))
Expand Down

0 comments on commit 574feb9

Please sign in to comment.