LinuxQuestions.org
Visit Jeremy's Blog.
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 05-08-2006, 07:04 AM   #1
user1029
LQ Newbie
 
Registered: May 2006
Posts: 2

Rep: Reputation: 0
iptables


Hi there, i am new to iptables and i need to find out how to implement following rules:

setup default policies of DROP for the input chain and REJECT for the other 2 default chains.
ii) allow any input/output traffic over the loopback interface ie lo
iii) deny any incoming packets claiming to be from your IP address and log them
iv) deny any packets from/to the following networks and log them
class A 10.0.0.0 NB class A networks have an 8-bit netmask
class B 72.16.0.0 NB class B networks have a 16-bit netmask
Class D 224.0.0.0 with a 4 bit netmask
Class E 240.0.0.0 with a 5 bit netmask
v) deny incoming/outgoing packets on eth0 which have an address of 127.0.0.1 and log them


Thanks for any help.
 
Old 05-08-2006, 07:37 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 683Reputation: 683Reputation: 683Reputation: 683Reputation: 683Reputation: 683
This site has a policy against doing people's homework problems.

iptables is the program that sets up netfilters tables. There is documentation at the netfilter homepage: http://www.netfilter.org/
 
Old 05-08-2006, 07:48 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 683Reputation: 683Reputation: 683Reputation: 683Reputation: 683Reputation: 683
Also check in /usr/share/doc/packages/iptables/packet-filtering-HOWTO.html. This directory may also contain documentation on NAT.
 
Old 05-08-2006, 12:15 PM   #4
Linux~Powered
Member
 
Registered: Jan 2004
Location: /lost+found
Distribution: Slackware 14.2
Posts: 849

Rep: Reputation: 33
This should work for you.

Quote:
setup default policies of DROP for the input chain and REJECT for the other 2 default chains.
iptables -F
iptables -X
iptables -N LOG_DROP

#Default policies..

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

Quote:
deny any packets from/to the following networks and log them
#Log rules...

iptables -A INPUT -i eth0 -s 10.0.0.0/8 -j LOG_DROP
iptables -A INPUT -i eth0 -s 224.0.0.0/4 -j LOG_DROP
iptables -A INPUT -i eth0 -s 240.0.0.0/5 -j LOG_DROP
iptables -A INPUT -i eth0 -s 172.16.0.0/12 -j LOG_DROP

#Drop them...

iptables -A INPUT -i eth0 -s 10.0.0.0/8 -j DROP
iptables -A INPUT -i eth0 -s 224.0.0.0/4 -j DROP
iptables -A INPUT -i eth0 -s 240.0.0.0/5 -j DROP
iptables -A INPUT -i eth0 -s 172.16.0.0/12 -j DROP

Quote:
ii) allow any input/output traffic over the loopback interface ie lo
# Allow loopback connections.

iptables -A INPUT -i lo -j ACCEPT

# Rules for logging packets.

iptables -A LOG_DROP -j LOG --log-prefix "[IPTABLES DROP] : " --log-tcp-options --log-ip-options --log-level 3


Edit your syslog.conf file by adding these two lines...

# Log rc.firewall packets.
kern.3 /var/log/firewall

Restart syslogd and your done.
 
Old 05-15-2006, 08:07 AM   #5
user1029
LQ Newbie
 
Registered: May 2006
Posts: 2

Original Poster
Rep: Reputation: 0
Thank you Linux~Powered so much. I really appreciate your help.
 
  


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
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 v1.2.9: Unknown arg `/sbin/iptables' Try `iptables -h' or 'iptables --help' Niceman2005 Linux - Security 4 12-29-2005 08:20 PM
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 - Security

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