LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-18-2003, 05:01 PM   #1
nakkaya
LQ Guru
 
Registered: Jan 2003
Location: Turkey&USA
Distribution: Emacs and linux is its device driver(Slackware,redhat)
Posts: 1,398

Rep: Reputation: 45
iptables


i checked the how to but i am just trying to close all ports and open just port 80 for www can any one tell me the command to do that with iptables?
 
Old 01-18-2003, 06:16 PM   #2
Ztyx
Member
 
Registered: Dec 2001
Location: Stockholm, Sweden
Distribution: Ubuntu, Kubuntu and Debian
Posts: 338

Rep: Reputation: 30
Code:
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT
This should probably work...
 
Old 01-18-2003, 11:55 PM   #3
nakkaya
LQ Guru
 
Registered: Jan 2003
Location: Turkey&USA
Distribution: Emacs and linux is its device driver(Slackware,redhat)
Posts: 1,398

Original Poster
Rep: Reputation: 45
when i did that it blocked all the ports
 
Old 01-19-2003, 04:02 AM   #4
Ztyx
Member
 
Registered: Dec 2001
Location: Stockholm, Sweden
Distribution: Ubuntu, Kubuntu and Debian
Posts: 338

Rep: Reputation: 30
Code:
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A OUTPUT ! -p tcp -j DROP
iptables -A OUTPUT -p tcp --syn -j DROP
But as you probably can understand both of these rulesets only allows your webserver to communicate to the net. You will not be able to surf on the box aswell or do anything else...
 
Old 01-19-2003, 06:49 AM   #5
nakkaya
LQ Guru
 
Registered: Jan 2003
Location: Turkey&USA
Distribution: Emacs and linux is its device driver(Slackware,redhat)
Posts: 1,398

Original Poster
Rep: Reputation: 45
sorry for misunderstanding i just want the browser to work that s why i said port 80 becouse http port is 80 but i need surf
 
Old 01-19-2003, 08:57 AM   #6
ddpicard
Member
 
Registered: Oct 2001
Location: Texas
Distribution: Slackware 13
Posts: 214

Rep: Reputation: 31
You can always try firestarter or shorewall. I have shorewall running on my slackware 8.1 and it works great. Just follow the instructions and it will walk you through the setup. Here is the link:

http://shorewall.sourceforge.net/

dave
 
Old 01-19-2003, 09:22 AM   #7
Ztyx
Member
 
Registered: Dec 2001
Location: Stockholm, Sweden
Distribution: Ubuntu, Kubuntu and Debian
Posts: 338

Rep: Reputation: 30
Hmm, you have to be even more specific;
- Block ALL incoming connections to your computer? Yes, that's what you want isn't it?
- ONLY allow websurfing on the computer? Are these firewall rules intended to block the use of the computer for anything else than surfing the web?
- Should FTP be turned on as some services on the web require it?
 
Old 01-19-2003, 09:29 AM   #8
nakkaya
LQ Guru
 
Registered: Jan 2003
Location: Turkey&USA
Distribution: Emacs and linux is its device driver(Slackware,redhat)
Posts: 1,398

Original Poster
Rep: Reputation: 45
i want to block all ports except dhcp web ftp icq thats what i wanna do with ip tables
 
Old 01-19-2003, 04:05 PM   #9
Ztyx
Member
 
Registered: Dec 2001
Location: Stockholm, Sweden
Distribution: Ubuntu, Kubuntu and Debian
Posts: 338

Rep: Reputation: 30
Ah; then do:

Code:
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
iptables -A INPUT -p tcp  --syn -j DROP
This is a very basic firewall although it should deny most of the incoming connections. Every firewall is configured differently depending on what you run on your system so I suggest you read the HOWTO as it is very good to know how to create one that fits your purpose.

Sheers.
 
Old 01-24-2003, 06:43 AM   #10
Grim Reaper
Member
 
Registered: Apr 2002
Distribution: Gentoo 2006.0 AMD64
Posts: 399

Rep: Reputation: 30
what Ztyx said, but where is this NAT table your talking about? AFAIK, IPTables doesn't have a NAT table by default...all it has is INPUT, OUTPUT and FORWARD...

to simplify things he could just:

iptables -F
iptables -A INPUT -p tcp --syn -j DROP

That's all i think he'd need...
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
An error occured getting IPtables status from the command /etc/rc.d/init.d/iptables s CrazyMAzeY Linux - Newbie 10 08-12-2010 05:25 AM
Iptables - Couldn't load target `ACCPET':/lib/iptables/libipt_ACCPET.so: z00t Linux - Security 3 01-26-2004 02:24 AM
IPtables Log Analyzer from http://www.gege.org/iptables/ brainlego Linux - Software 0 08-11-2003 06:08 AM
iptables book wich one can you pll recomment to be an iptables expert? linuxownt Linux - General 2 06-26-2003 04:38 PM
My iptables script is /etc/sysconfig/iptables. How do i make this baby execute on boo ForumKid Linux - General 3 01-22-2002 07:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:01 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