LinuxQuestions.org
Visit Jeremy's Blog.
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 06-02-2004, 08:15 PM   #1
veritas
Member
 
Registered: Aug 2003
Location: Dallas,TX
Distribution: Ubuntu Server, Slackware, Red Hat 6.1
Posts: 241

Rep: Reputation: 30
What's wrong with my iptables script?


Here's the basic overview of what I want out of my firewall:

1) allow local loopback and allow it to be pinged
2) drop every other ping packet from outside my computer
3) allow apache access
4) drop everything else

And here is what i pieced together with a few LQ searches:

Code:
iptables -F

#drop everything
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP

#allow http
iptables -A INPUT -p tcp -s 0/0 --dport 80:81 -j ACCEPT

# Allow the loopback interface to be used by local machine

iptables -A INPUT -i lo -p all -j ACCEPT
iptables -A OUTPUT -o lo -p all -j ACCEPT

# Allow established connections

iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --tcp-option ! 2 -j REJECT --reject-with tcp-reset
With this configuration i can ping localhost/127.0.0.1 but I can also ping my actual IP address, which I don't want. What can I change to make it match my criteria?

Thanks,
Wes
 
Old 06-02-2004, 09:06 PM   #2
Mathieu
Senior Member
 
Registered: Feb 2001
Location: Montreal, Quebec, Canada
Distribution: RedHat, Fedora, CentOS, SUSE
Posts: 1,403

Rep: Reputation: 46
From where are you ping-ing ?

If you are doing it from your computer (the PC with the above mentioned rules), you will be able to ping your IP.
Why: Because OUTPUT is set to ACCEPT.
In this case, packets (ping) are coming from lo and leaving by OUTPUT.

However, if you ping from another PC, your PC will drop all ping packets.


Plus, since your OUTPUT is set to ACCEPT, the following line is not needed
Code:
iptables -A OUTPUT -o lo -p all -j ACCEPT

Last edited by Mathieu; 06-02-2004 at 09:08 PM.
 
Old 06-05-2004, 09:55 PM   #3
veritas
Member
 
Registered: Aug 2003
Location: Dallas,TX
Distribution: Ubuntu Server, Slackware, Red Hat 6.1
Posts: 241

Original Poster
Rep: Reputation: 30
Hey, thanks for the reply and sorry for my late followup. Anyways, I took out the
Code:
iptables -A OUTPUT -o lo -p all -j ACCEPT
line just like you said, since it was not needed.

I guess it really doesn't matter if I can ping my IP address locally, because my friend can't ping it from his computer, so that's good. (I originally thought my last iptables configuration had it set to where I couldn't ping my IP locally, but apparently not)

Thanks,
Wes
 
Old 06-06-2004, 11:39 AM   #4
tuxq
Member
 
Registered: Feb 2003
Location: USA
Distribution: Slackware-current
Posts: 47

Rep: Reputation: 15
I only have on suggestion...
http://www.lowth.com/LinWiz/1.09/Ser...fw.pl/iptables
Very nice ... =)
 
  


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
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 04:19 AM
iptables script sets wrong dynamic IP gundelgauk Linux - Security 5 09-08-2003 07:42 AM
iptables - somthing gone wrong ? qwijibow Linux - Security 7 09-01-2003 11:56 AM
iptables, what am i doing wrong?! jimval7 Linux - Networking 5 02-27-2002 11:29 AM
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 - Security

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