LinuxQuestions.org
Help answer threads with 0 replies.
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-07-2006, 12:05 AM   #1
shipon_97
Member
 
Registered: Oct 2005
Location: Bangladesh
Posts: 497

Rep: Reputation: 30
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-07-2006, 12:20 AM   #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-07-2006 at 12:23 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 12:03 PM
Iptables help, block port to outside but open to inside. Brian1 Linux - Networking 2 09-27-2005 09:41 PM
Is it possible to block text strings with IP tables? abefroman Linux - Security 27 06-29-2005 06:36 PM
Setting ip tables to block all traffic LinuxBAH Linux - Security 1 02-07-2004 07:15 AM
Iptable-rules block port 80 goldenmag Linux - Security 3 09-05-2003 07:56 PM

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

All times are GMT -5. The time now is 06:28 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration