Skip to content

Commit a7193f5

Browse files
chemikadzebrianmay
authored andcommitted
Fix capturing of local DNS servers
Regression was introduced in sshuttle#337 that is skipping all local traffic, including DNS. This change makes UDP port 53 (DNS) LOCAL traffic to be treated as special case. Fixes sshuttle#357
1 parent 7ebff92 commit a7193f5

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

sshuttle/methods/nat.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ def _ipm(*args):
5454
# tunnelling the traffic designated to all local TCP/IP addresses.
5555
_ipt('-A', chain, '-j', 'RETURN',
5656
'-m', 'addrtype',
57-
'--dst-type', 'LOCAL')
57+
'--dst-type', 'LOCAL',
58+
'!', '-p', 'udp')
59+
# Skip LOCAL traffic if it's not DNS.
60+
_ipt('-A', chain, '-j', 'RETURN',
61+
'-m', 'addrtype',
62+
'--dst-type', 'LOCAL',
63+
'-p', 'udp', '!', '--dport', '53')
5864

5965
# create new subnet entries.
6066
for _, swidth, sexclude, snet, fport, lport \

tests/client/test_methods_nat.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ def test_setup_firewall(mock_ipt_chain_exists, mock_ipt_ttl, mock_ipt):
140140
call(AF_INET, 'nat', '-I', 'OUTPUT', '1', '-j', 'sshuttle-1025'),
141141
call(AF_INET, 'nat', '-I', 'PREROUTING', '1', '-j', 'sshuttle-1025'),
142142
call(AF_INET, 'nat', '-A', 'sshuttle-1025', '-j', 'RETURN',
143-
'-m', 'addrtype', '--dst-type', 'LOCAL'),
143+
'-m', 'addrtype', '--dst-type', 'LOCAL',
144+
'!', '-p', 'udp'),
145+
call(AF_INET, 'nat', '-A', 'sshuttle-1025', '-j', 'RETURN',
146+
'-m', 'addrtype', '--dst-type', 'LOCAL',
147+
'-p', 'udp', '!', '--dport', '53'),
144148
call(AF_INET, 'nat', '-A', 'sshuttle-1025', '-j', 'RETURN',
145149
'--dest', u'1.2.3.66/32', '-p', 'tcp', '--dport', '8080:8080')
146150
]

0 commit comments

Comments
 (0)