Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
08-07-2007, 07:37 PM
|
#1
|
Member
Registered: Aug 2007
Distribution: Gentoo 2007.0
Posts: 51
Rep:
|
Blocking specific outbound traffic - iptables
I know this seems like a simple question, but I have searched all over the place and can't seem to find an answer.
Question: How do I block outbound traffic, from the local computer (i.e. this firewall is NOT forwarding traffic for any other computers)? I only want to use bittorrent, browse the internet, and connect to other computers (but not let them initiate connections with me) via SSH. Other than that, there should be no incoming or outbound traffic. What would a simple iptables script for this look like?
It's wierd that I couldn't find the answer to this, but it seems like all of the documentation and forum posts I've found seem to only discuss the INPUT chain and FORWARD chains, or is discussing a computer used as a firewall for multiple computers, that is forwarding traffic. All I want to do though is protect the computer the firewall is installed on.
Any help would be appreciated....
Mr. Snorfles
|
|
|
08-07-2007, 08:58 PM
|
#2
|
Member
Registered: Aug 2007
Distribution: Gentoo 2007.0
Posts: 51
Original Poster
Rep:
|
SOLVED: Host-Based Firewalls
I did some more research and found exactly what I needed:
http://www.sun.com/blueprints/1103/817-4403.pdf
I didn't know that I was looking for "Host-based" firewalls. But now that I know the search term - all is well...
Hope this is helpful!
--Mr. Snorfles
|
|
|
08-08-2007, 03:11 AM
|
#4
|
Member
Registered: Aug 2007
Distribution: Gentoo 2007.0
Posts: 51
Original Poster
Rep:
|
Interesting link
Interesting link...
Thanks!
--Mr. Snorfles
|
|
|
08-08-2007, 02:23 PM
|
#5
|
LQ Guru
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870
|
Quote:
Originally Posted by mistersnorfles
How do I block outbound traffic, from the local computer (i.e. this firewall is NOT forwarding traffic for any other computers)? I only want to use bittorrent, browse the internet, and connect to other computers (but not let them initiate connections with me) via SSH. Other than that, there should be no incoming or outbound traffic. What would a simple iptables script for this look like?
|
It would look like this:
Code:
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
# BitTorrent (Tracker):
iptables -A OUTPUT -p TCP --dport 6969 \
-m state --state NEW -j ACCEPT
# BitTorrent (P2P Connections):
iptables -A OUTPUT -p TCP --dport 6881:6999 \
-m state --state NEW -j ACCEPT
# HTTP:
iptables -A OUTPUT -p TCP --dport 80 \
-m state --state NEW -j ACCEPT
# HTTPS:
iptables -A OUTPUT -p TCP --dport 443 \
-m state --state NEW -j ACCEPT
# DNS:
iptables -A OUTPUT -p UDP --dport 53 \
-m state --state NEW -j ACCEPT
# DNS (TCP fallback):
iptables -A OUTPUT -p TCP --dport 53 \
-m state --state NEW -j ACCEPT
# SSH:
iptables -A OUTPUT -p TCP --dport 22 \
-m state --state NEW -j ACCEPT
The same thing, but more condensed:
Code:
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A OUTPUT -p TCP \
-m multiport --dports 6969,6881:6999,80,443,53,22 \
-m state --state NEW -j ACCEPT
iptables -A OUTPUT -p UDP --dport 53 \
-m state --state NEW -j ACCEPT
Last edited by win32sux; 08-08-2007 at 02:26 PM.
|
|
|
08-08-2007, 03:14 PM
|
#6
|
Member
Registered: Aug 2007
Distribution: Gentoo 2007.0
Posts: 51
Original Poster
Rep:
|
Exactly what I had just made
thanks anyway though, win32
|
|
|
All times are GMT -5. The time now is 12:16 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|