LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-06-2006, 11:05 PM   #1
shipon_97
Member
 
Registered: Oct 2005
Location: Bangladesh
Posts: 504

Rep: Reputation: 31
Cool Block/open all port using IP Tables rules


Dear Frndz,

I have the following Two Scenario :

1) I want to Open All port in my Linux Server Except http(80) and https(443) Port .

2 ) I want to Close All port in my Linux Server Except http(80) and https(443) Port .

For the above scenario , What will be the "IP-tables" rules . Plz help according this regards .


Thx... ... ...
 
Old 09-06-2006, 11:20 PM   #2
matthalliday
Member
 
Registered: Jan 2006
Location: Brisbane, Australia
Distribution: Suse, Mandrake, IPCop, Debian, Slackware
Posts: 34

Rep: Reputation: 15
Open All Ports except 80 and 443

$ sudo iptables -F INPUT
$ sudo iptables -F OUTPUT
$ sudo iptables -F FORWARD
$ sudo iptables -P INPUT ACCEPT
$ sudo iptables -P OUTPUT ACCEPT
$ sudo iptables -P FORWARD ACCEPT
$ sudo iptables -A INPUT -p tcp -s 0/0 -d 0/0 --dport 80 -j DROP
$ sudo iptables -A INPUT -p tcp -s 0/0 -d 0/0 --dport 443 -j DROP

Close All Ports except 80 and 443

$ sudo iptables -F INPUT
$ sudo iptables -F OUTPUT
$ sudo iptables -F FORWARD
$ sudo iptables -P INPUT DENY
$ sudo iptables -P OUTPUT DENY
$ sudo iptables -P FORWARD DENY
$ sudo iptables -A INPUT -p tcp -i eth0 --dport 80 -j ACCEPT
$ sudo iptables -A INPUT -p tcp -i eth0 --dport 443 -j ACCEPT

These is untested as I don't have the time, however that should be right (If not, it will give you a good start).

Everyone else, please correct me when needed.

*Edit
Please note: You may (should) flush your IP Tables before doing this.

Cheers,

Last edited by matthalliday; 09-06-2006 at 11:23 PM.
 
  


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
My ip-tables rules prevents samba (nmbd) from starting pingu Linux - Software 2 01-18-2006 11:03 AM
Iptables help, block port to outside but open to inside. Brian1 Linux - Networking 2 09-27-2005 08:41 PM
Is it possible to block text strings with IP tables? abefroman Linux - Security 27 06-29-2005 05:36 PM
Setting ip tables to block all traffic LinuxBAH Linux - Security 1 02-07-2004 06:15 AM
Iptable-rules block port 80 goldenmag Linux - Security 3 09-05-2003 06:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:05 AM.

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