Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

On a Linux system, is there a way to block all in and outbound traffic unless it passes through the Tor network. This includes any form of IP communication, not just TCP connections. For example I want UDP to be completely blocked since it cannot pass through Tor. I want this systems Internet usage to be entirely anonymous, and I don't want any applications leaking.

I realize this might be complicated because Tor itself needs to communicate with relay nodes somehow.

share|improve this question
I was just about to ask a similar question :) – amyassin Oct 2 '12 at 11:55
2  
For those of you casting close votes, I would like to remind you that there are valid business use cases for Tor. – Michael Hampton Oct 8 '12 at 3:17

1 Answer

up vote 21 down vote accepted

Easy enough with iptables. It can have rules which match specific users, and you should have already set up tor to run under its own user ID.

A sample (and incomplete) configuration. In this example, the username is toranon (the default on Red Hat derived systems):

iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

iptables -I INPUT 1 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -I INPUT 2 -i lo -j ACCEPT

iptables -I OUTPUT 1 -m owner --uid-owner toranon -j ACCEPT

Keep in mind that this blocks everything not initiated by tor or confined to the local host, and so that includes things like DHCP...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.