Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Security
User Name
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.


  Search this Thread
Old 02-01-2011, 01:25 AM   #1
LQ Newbie
Registered: Feb 2011
Posts: 1

Rep: Reputation: Disabled
Q: How to Drop inbound traffic to port 80 (http) from source ports less than 1024?


I'm simply trying to make a little restriction on www packets under two rules:

1. Allow inbound/outbound www packets (works!)
2. DROP inbound traffic to port 80 from source ports less than 1024. (DOES NOT WORK!)

Now, technically, when i use hping to test my rules,
hping3 -S -p80 -s 1023
I should NOT receive any packets.
However, i still receive packets, which means my rule that says less than 1024 does not work. (see below)

Does anyone know why?

And this is my iptables rules in shell-script so far:


# Flushing all rules

# DROP all incomming traffic

# Permit inbound www(80) packets.
$IPT -A INPUT -p tcp -i $DEFAULT_NIC -s 0/0 -d $SERVER_IP --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp -o $DEFAULT_NIC -s $SERVER_IP --sport 80 -d 0/0 -m state --state ESTABLISHED -j ACCEPT

# Permit outbound www(80) packets.
$IPT -A OUTPUT -p tcp -o $DEFAULT_NIC -s $SERVER_IP -d 0/0 --dport $ALLOWED_WWW_PORT -m state --state NEW,ESTABLISHED -j ACCEPT
$IPT -A INPUT -p tcp -i $DEFAULT_NIC -s 0/0 --sport $ALLOWED_WWW_PORT -d $SERVER_IP -m state --state ESTABLISHED -j ACCEPT

# Drop inbound traffic to port 80(http) from source ports less than 1024
$IPT -A INPUT -p tcp -i $DEFAULT_NIC -s 0/0 --sport 0:1023 -d $SERVER_IP --dport 80 --syn -j DROP

# Log and drop all other packets to file /var/log/messages
iptables -A OUTPUT -j LOG
iptables -A INPUT -j LOG
iptables -A FORWARD -j LOG

# make sure nothing comes or goes out of this box
iptables -A OUTPUT -j DROP
iptables -A INPUT -j DROP
iptables -A FORWARD -j DROP

# save, restart, and check the iptables
service iptables save
service iptables restart
iptables -L -n
Old 02-01-2011, 02:59 AM   #2
LQ Guru
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 377Reputation: 377Reputation: 377Reputation: 377
I'd say it's because of the order of your rules. Perhaps make the DROP rule first in the chain and try again? Otherwise, you're sending the packets to ACCEPT before they ever have a chance to match the DROP rule.

Last edited by win32sux; 02-01-2011 at 03:01 AM.
1 members found this post helpful.


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
Firewall deny traffic inbound destination port 53372 & 53375 Brent Pasley Linux - Security 1 05-05-2010 02:28 PM
LXer: Linux HTTP Port 80 Outgoing Traffic Shaping LXer Syndicated Linux News 0 04-14-2010 02:50 PM
replicate traffic from all ports to monitor port gizza23 Linux - Networking 4 01-14-2009 02:39 PM
what is the inbound traffic adam_blackice Linux - Security 4 12-13-2007 08:37 PM
Inbound traffic for port 80 Gerardoj Linux - Networking 10 05-29-2003 04:27 PM > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 05:44 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration