LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-2011, 01:25 AM   #1
snowfish
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?


Hi,

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 192.168.100.100 -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:

#!/bin/sh
DEFAULT_NIC=eth0
SERVER_IP="192.168.100.100"
ALLOWED_WWW_PORT=80
IPT="/sbin/iptables"

clear
# Flushing all rules
$IPT -F
$IPT -X

#---------------------------------------------------------------
# DROP all incomming traffic
#---------------------------------------------------------------
$IPT -P INPUT DROP
$IPT -P FORWARD DROP
$IPT -P OUTPUT DROP

#---------------------------------------------------------------
# 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
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
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.
  


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
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


All times are GMT -5. The time now is 10:24 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration