LinuxQuestions.org
Help answer threads with 0 replies.
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 02-01-2007, 11:58 PM   #1
spoonpower
LQ Newbie
 
Registered: Sep 2006
Posts: 16

Rep: Reputation: 0
Need help building firewall Iptables


Hi everyone,

Thank you for for reading this thread. I am currently building a simple firewall and dont' quite understand what does it mean by " Drop all incoming packets from reserved port 0 as well as inbound traffic to port 0" The following below is the few rules that I made so far. Can anyone tell me what is the script look like to drop all incoming packet & traffic for reserved port 0. Also, if you see any error on my scirpt, please let me know.

# Set the default policies to DROP
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP

# Permit inbound/outbound ssh packets.
iptables -A INPUT -i eth1 -p tcp --dport 22 -- syn -j ACCEPT
iptables -A OUTPUT -o eth1 -p tcp --sport 22 -- syn -j DROP

# Permit inbound/outbound www packets.
iptables -A INPUT -i eth1 -p tcp --dport 80 -- syn -j ACCEPT
iptables -A OUTPUT -o eth1 -p tcp --sport 80 -- syn -j DROP

# Drop inbound traffic to port 80 (http) from source ports less than 1024
iptables -A INPUT -i eth1 -p tcp --dport 80 --sport 0:1024 -j DROP

# Drop all incoming packets from reserved port 0 as well as inbound traffic to port 0
 
Old 02-02-2007, 01:55 AM   #2
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
Port 0 should be blocked:

http://www.ouah.org/port0paper.txt

For understanding iptables:
man iptables
+
google
or use firestarter or guarddog which will generate your rules based on simple questions
 
Old 02-03-2007, 11:52 AM   #3
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
You really shouldn't be trying to "roll your own" firewall w/ so little background knowledge, If you are determined to learn how, a commendable goal, look at Oscar Andreasson's Iptables Tutorial 1.2.2
 
Old 02-06-2007, 02:18 AM   #4
spoonpower
LQ Newbie
 
Registered: Sep 2006
Posts: 16

Original Poster
Rep: Reputation: 0
Hi, cause I am currently working on my school assignment, really want to get some help, due to my little knowledge on linux and firewall. I am using Fedora 6, how can I execute the firewall when bootup? Also, can anyone please take a look my scipts and tell me where is wrong? I really appreciated. Thanks

# Set the default policies to DROP
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP

# Allow the localhost
iptables -A INPUT -i lo -j ACCEPT

# Permit inbound/outbound ssh packets.
iptables -A INPUT -p tcp --dport 22 --syn -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 --syn -j ACCEPT

# Permit inbound/outbound www packets.
iptables -A INPUT -p tcp --dport 80 --syn -j ACCEPT
iptables -A OUTPUT -p tcp --sport 80 --syn -j ACCEPT

# Drop inbound traffic to port 80 (http) from source ports less than 1024
iptables -A INPUT -p tcp --dport 80 --sport 0:1024 -j DROP

# Drop all incoming packets from reserved port 0 as well as inbound traffic to port 0
iptables -A INPUT -p tcp --dport 0 -j DROP
iptables -A INPUT -p tcp --sport 0 -j DROP

# Allow DNS traffic through this machine
iptables -A INPUT -p udp --dport 53 -j ACCEPT

# Allow DHCP traffic throught this machine
iptables -I INPUT -p udp --dport 67:68 -j ACCEPT

# Create user-defined chains to keep track of the ssh & www traffic v.s the rest of the system
iptables -N definedtraffic
iptables -N resttraffic
iptables -A definedtraffic -j ACCEPT
iptables -A resttraffic -j ACCEPT
iptables -A FORWARD -i eth1 -m tcp -p tcp --sport 22 -j definedtraffic
iptables -A FORWARD -i eth1 -m tcp -p tcp --sport 80 -j definedtraffic
iptables -A FORWARD -j resttraffic
 
Old 02-08-2007, 04:44 AM   #5
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Is this homework?

What have you done to help yourself?

Where are you located?
 
  


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
Iptables with iptables-firewall.conf arno's matt3333 Slackware 16 06-28-2007 07:20 AM
Building a Firewall wwnexc Linux - Networking 6 01-11-2006 10:10 AM
Building a firewall/gateway Mogwa_ Linux - Networking 1 07-13-2004 06:42 AM
help building my firewall rules rhawi Linux - Security 19 05-16-2004 09:29 PM
Need Help In Building a Web-based Firewall Configuration Tool for Linux(RH9-iptables) eason Linux - General 1 02-21-2004 05:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

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