LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 02-15-2003, 12:28 AM   #1
linowes
Member
 
Registered: Sep 2002
Location: New Hampshire
Distribution: RH8.0
Posts: 55

Rep: Reputation: 15
learning iptables


hi,
can I get a sanity check? here's my iptables script, for a firewall on my home network, and the result of iptables -L
is this working?
(also, the LOG line makes my hard disk thrash terribly so I commented it out). This is from an article I found on the web. Thanks!

/sbin/modprobe iptable_nat
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A INPUT -i lo -j ACCEPT
# /sbin/iptables -A INPUT -j LOG --log-level 4 --log-prefix "ATTACK"
/sbin/iptables -A INPUT -j DROP
/sbin/iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE

when i run iptables -L here'swhat I get

Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT all -- anywhere anywhere
DROP all -- anywhere anywhere

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
 
Old 02-18-2003, 06:27 AM   #2
Sutekh
Member
 
Registered: Apr 2002
Location: Melbourne, Australia
Distribution: Gentoo
Posts: 273

Rep: Reputation: 30
a couple of things....

1st best to make the defaut policy of all chains DENY and then selectively let though what you want so

iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

then accept anything from the actual firewall machine and any other local machines

iptables -A INPUT -i lo -j ACCEPT // this line is fine but add

iptables -A INPUT -i eth1 -j ACCEPT //assuming that eth1 is the card connected to your local network

i would change
/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

to

iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT

that way any local traffic will travel unimpeeded to the firewall

you will also want to create a rule for forwarding
iptables -A FORWARD -i eth0 -d 192.168.0.0/24 -m state --state ESTABLISHED,RELATED -j ACCEPT
or something like that. Also

iptables -A FORWARD -i eth1 -j ACCEPT

and then through in your MASQUERADE line at the end.

** NOTE ** this is far from a perfect firewall, it is a start, more secure than the one you posted but really needs some more work before you should rely on it. My advice is to shut down everything and then selectively open it up until you have a working system. I aslo recommend checking out this link on Connection Tracking

Rich
 
Old 02-18-2003, 01:43 PM   #3
linowes
Member
 
Registered: Sep 2002
Location: New Hampshire
Distribution: RH8.0
Posts: 55

Original Poster
Rep: Reputation: 15
thanks!
(the Connection Tracking article will take some study
now I want to be able to ping this machine from inside my lan but it is blocked.
 
Old 02-19-2003, 03:36 PM   #4
linowes
Member
 
Registered: Sep 2002
Location: New Hampshire
Distribution: RH8.0
Posts: 55

Original Poster
Rep: Reputation: 15
Thanks for our answers to this and my related thread here. Some one suggested an excellent article at http://www.linuxsecurity.com/resourc...-tutorial.html which covers it for me.
 
  


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
About learning C dludenar Fedora 3 10-04-2005 09:27 AM
Learning IPTables on RedHat 9 fazzy Linux - Security 2 11-02-2004 09:28 AM
Learning C/C++ Debian-Gnu-B Linux - Software 12 01-28-2004 03:20 PM
Learning? slack105 Slackware 3 07-31-2003 12:46 PM
learning how much mb? nakkaya Linux - General 4 02-27-2003 10:04 AM

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

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