LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 10-12-2015, 11:55 AM   #1
hack3rcon
Senior Member
 
Registered: Jan 2015
Posts: 1,432

Rep: Reputation: 11
Post Block all Incoming connection and just open port 9050 and 9051


Hello.
How can I use iptables in Debian for close all incoming connection and just open port 9050 and 9051 for Tor ?

Thank you.
 
Old 10-12-2015, 02:47 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
To block everything, set DROP as a policy. You can also use REJECT, which means that the party that tries to connect will receive an ICMP packet as a reply.
To open 9050 and 9051, add two rules. I don't know whether Tor uses TCP or UDP, so adapt it if necessary.
Code:
iptables -P INPUT DROP
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 9050 -j ACCEPT
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 9051 -j ACCEPT
The two ACCEPT lines can also be fused into one by specifying a port range.
 
3 members found this post helpful.
Old 10-13-2015, 02:58 PM   #3
linxpatrick
Member
 
Registered: Oct 2010
Posts: 32

Rep: Reputation: 1
I don't use Debian Linux so I don't know if anything is installed by default but there are GUI tools that can help you set firewall rules. For example, OpenSUSE comes with a tool that is accessible with yast and I have installed FirewallBuilder for Ubuntu, which I believe would also work on OpenSUSE. If you wish to learn how to set iptables rules directly you can set them using one of these tools and then review them from the iptables command line.
 
Old 10-15-2015, 03:26 AM   #4
hack3rcon
Senior Member
 
Registered: Jan 2015
Posts: 1,432

Original Poster
Rep: Reputation: 11
Quote:
Originally Posted by berndbausch View Post
To block everything, set DROP as a policy. You can also use REJECT, which means that the party that tries to connect will receive an ICMP packet as a reply.
To open 9050 and 9051, add two rules. I don't know whether Tor uses TCP or UDP, so adapt it if necessary.
Code:
iptables -P INPUT DROP
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 9050 -j ACCEPT
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 9051 -j ACCEPT
The two ACCEPT lines can also be fused into one by specifying a port range.
Thank you.
Tor just use TCP.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Open outgoing / block incoming JJJCR Linux - Security 6 12-22-2014 04:15 AM
open incoming port 8080 golriz Linux - Networking 3 05-16-2011 06:44 AM
Howto deny incoming connection to port 80? sys7em Linux - Security 5 10-31-2004 01:19 PM
How do I open port 25 to allow incoming email? ei2ie Linux - Networking 5 10-18-2003 01:02 AM
Block incoming port Iptables cli_man Linux - Networking 5 08-11-2003 08:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 12:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration