LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 07-19-2005, 05:21 AM   #1
saugato
LQ Newbie
 
Registered: Jan 2005
Posts: 15

Rep: Reputation: 0
limited internal ip access


Hi,

I have configured a iptables firewall, it was runnning fine . All the private ip pool of 192.168.0.0 was given access to internet through static natting.

but now i want let only a selected number of ips get access. please advice on the sysntax. I am also pasting the script for your referral. pls suggest changes to that if you have any. But main issue is to limit the number of users, say want to let only 10 users in the default subnet only to access internet. what is the syntax that i shud use instead of 192.168.0.0/24.

ptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

#icoming packets from lan
iptables -A INPUT -p ALL -i eth1 -s 192.168.0.0/24 -j ACCEPT
iptables -A INPUT -p ALL -i lo -s 127.0.0.1 -j ACCEPT
iptables -A INPUT -p ALL -i lo -s 192.168.0.1 -j ACCEPT
iptables -A INPUT -p ALL -i eth1 -s 192.168.0.255 -j ACCEPT

# WAN LINES
iptables -A INPUT -p ALL -d [wan ip addrss] -m state --state ESTABLISHED,RELATED -j ACCEPT

# TCP RULE

iptables -A INPUT -p TCP -i eth0 -s 0/0 --destination-port 22 -j ACCEPT

#OTHER RULES WAN
iptables -A INPUT -p ALL -i eth0 -s 0/0 --destination-port 25 -j ACCEPT
iptables -A INPUT -p ALL -i eth0 -s 0/0 --destination-port 110 -j ACCEPT

#ICMP RULE
iptables -A INPUT -p ICMP -i eth0 -s 0/0 icmp-type 8 -j ACCEPT
iptables -A INPUT -p ICMP -i eth0 -s 0/0 icmp-type 11 -j ACCEPT

# FORWARD RULE
iptables -A FORWARD -i eth1 -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

#SPOOFING
ipatables -A OUTPUT -p ALL -s 127.0.0.1 -j ACCEPT
iptables -A OUTPUT -p ALL -s 192.168.0.1 -j ACCEPT
iptables -A OUTPUT -p ALL -s [WAN IP] -j ACCEPT

#NAT
iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to-source [WAN IP]
 
Old 07-19-2005, 09:33 AM   #2
cdhgee
Member
 
Registered: Oct 2003
Location: St Paul, MN
Distribution: Fedora 8, Fedora 9
Posts: 513

Rep: Reputation: 30
The easiest thing to do is to use the x.x.x.x./y syntax, but to lock it down further. For example, 192.168.0.0/28 is defined as the subnet 192.168.0.0-192.168.0.15 (there are 16 addresses in this subnet, but 0.0 is the network address and 0.15 is the broadcast address, leaving 14 usable addresses).

Because it's a binary system, it has to work in powers of 2 - here's a more detailed list:

192.168.0.0/25: 192.168.0.0 - 192.168.0.127 (126 usable IPs)
192.168.0.0/26: 192.168.0.0 - 192.168.0.63 (62 usable IPs)
192.168.0.0/27: 192.168.0.0 - 192.168.0.31 (30 usable IPs)
192.168.0.0/28: 192.168.0.0 - 192.168.0.15 (14 usable IPs)
192.168.0.0/29: 192.168.0.0 - 192.168.0.7 (6 usable IPs)
192.168.0.0/30: 192.168.0.0 - 192.168.0.3 (2 usable IPs)
192.168.0.0/31: 192.168.0.0 - 192.168.0.1 (no usable IP addresses)

Of course, you don't have to stick with starting at the beginning of the 192.168.0 range - for example you could put your users somewhere in the middle of the range:

192.168.0.128/28: 192.168.0.128 - 192.168.0.143

If you're gonna do this though, be careful - the boundaries you start on have to be a multiple of the number of IP addresses in the range; so 192.168.0.128/28 is valid because 128 is a multiple of 16, but 192.168.0.136/28 is not valid because 128 is not a multiple of 16. If you used 192.168.0.136/29 however, it would be valid because 136 is a multiple of 8. You get the idea I hope!

Last edited by cdhgee; 07-19-2005 at 09:34 AM.
 
Old 07-20-2005, 07:38 AM   #3
saugato
LQ Newbie
 
Registered: Jan 2005
Posts: 15

Original Poster
Rep: Reputation: 0
Not working

Hi,

I have tried what you have suggested.
I wanted to actually give access to all ips after 32 so i did -----

iptables -A INPUT -p ALL -i eth1 -s 192.168.0.32/28 -j ACCEPT (in the incoming packets from lan section, i replaced the first line)

that means i have 16 ips in one pool and first usable ip in the above case should be 192.168.0.33,

But it seems to be not working. I tried with ips of 192.168.0.17, 192.168.0.5 all are working fine and accessing internet.
I should mention that i had flushed the iptables before doing this by using the command iptables -F

pls help urgent!!
 
Old 07-20-2005, 08:02 AM   #4
cdhgee
Member
 
Registered: Oct 2003
Location: St Paul, MN
Distribution: Fedora 8, Fedora 9
Posts: 513

Rep: Reputation: 30
Can you do

Code:
iptables-save > file.txt
and post the contents of the file so I can see the complete ruleset as it is at the moment.
 
  


Reply



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
Only limited writing access on FAT via NFS micha Linux - Networking 2 10-31-2005 02:37 AM
Limited Network access on Suse 9.3 bwdave Linux - Networking 1 09-14-2005 12:36 PM
Limited User Access Jakeh2k1 Red Hat 1 06-07-2005 07:03 AM
open_basedir - how do I provide limited access to other directories? benbroad Linux - Software 4 12-08-2004 06:07 AM
ssh limited access macadam Linux - Newbie 7 12-23-2003 01:06 PM

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

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