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
 
LinkBack Search this Thread
Old 11-09-2004, 04:44 PM   #1
Metroid
LQ Newbie
 
Registered: Jun 2003
Location: somewhere in some city
Distribution: Slackware 10.0, Debian
Posts: 12

Rep: Reputation: 0
Question iptables - network mask


Hello,

So here is my current problem

I am trying to filter all traffic on several ports down to a specific range of IP addresses. I have created a chain to do this called "filter" and another to jump too, named "allow", if the rule matches to accept the traffic.

Right now my filter chain looks like this, minus some stuff to let 192.168 in because both my comp and the firewall comp are behind a router for the moment.

iptables -A filter -s 123.123.0.0/255.255.155.0 -j DROP
iptables -A filter -s 123.123.0.0/255.255.105.0 -j allow
iptables -A filter -j DROP

With this i want only 123.123.100.x-123.123.150.x traffic to be accepted

The idea is a drop all packets below the range minimum then accept all the surviving packets below the range maximum. Anything left over gets dropped. Unfortunately the range max(2nd) rule doesn't seem to be matching..

I have not tested the first rule, range min, to see if it also doesn't match but commenting it out doesn't help so I'm ignoring it for now.

The IP i am testing it from would be 123.123.107.123

when i add a rule to allow 123.123.0.0/16 i can get in fine.

I have used this site to determine the values i use in my rules:
http://www.csgnetwork.com/ipinfocalc.html

"iptables -L -v" shows that the packets are getting dropped in the last rule above.

any ideas as to what may be wrong? also, any better ways to specify a specific IP range in an iptables rule?

thanks in advance.
 
Old 11-09-2004, 09:17 PM   #2
TruckStuff
Member
 
Registered: Apr 2002
Posts: 498

Rep: Reputation: 30
Re: iptables - network mask

Quote:
Originally posted by Metroid
iptables -A filter -s 123.123.0.0/255.255.155.0 -j DROP
iptables -A filter -s 123.123.0.0/255.255.105.0 -j allow
iptables -A filter -j DROP
Its late so someone correct me if I am wrong, but this isn't a valid subnet mask.

That's an awfully big block of IPs to allow traffic from. It would be easier to simply write your firewall as though it were accessible to everyone.

Last edited by TruckStuff; 11-09-2004 at 09:21 PM.
 
Old 11-09-2004, 09:45 PM   #3
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 46
This should help.
http://www.csc.fi/english/funet/calc/laskin2.html
 
Old 11-09-2004, 10:07 PM   #4
TruckStuff
Member
 
Registered: Apr 2002
Posts: 498

Rep: Reputation: 30
Quote:
Originally posted by /bin/bash
This should help.
http://www.csc.fi/english/funet/calc/laskin2.html
I was going to try to do the math to figure out all teh subnets, but its WAY too late for that.
 
Old 11-09-2004, 10:17 PM   #5
Metroid
LQ Newbie
 
Registered: Jun 2003
Location: somewhere in some city
Distribution: Slackware 10.0, Debian
Posts: 12

Original Poster
Rep: Reputation: 0
Thanks to both of you for replying. It probably is an invalid subnet mask which i was hoping wasn't the case. . iptables didn't complain to me when i added it so i was thinking it might still work. It was worth a shot. I should do some reading to get more up to speed on this.

That site looks like just what i need.

Thanks again!

Last edited by Metroid; 11-09-2004 at 10:19 PM.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Subnet Mask with 1 IP. Ionized Linux - Networking 25 06-10-2007 12:20 AM
mask ip windows xp newuser455 General 7 03-21-2005 01:13 PM
URL mask brain_bucket Linux - Networking 2 06-19-2004 02:33 AM
All network/broadcast pairs for subnet mask? debbo Linux - Networking 1 06-14-2004 04:27 PM
Subnet mask mikeshn Linux - Networking 1 08-26-2002 01:19 PM


All times are GMT -5. The time now is 04:16 PM.

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
Open Source Consulting | Domain Registration