Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Joel Newkirk <newkirk@newkirk.us>
To: netfilter@lists.netfilter.org
Subject: Re: help to build a small firewall for a child
Date: Mon, 24 Mar 2003 03:34:57 -0500	[thread overview]
Message-ID: <200303240334.57004.newkirk@newkirk.us> (raw)
In-Reply-To: <Pine.LNX.4.50.0303232012210.4365-100000@dragonII.tasso.info>

On Sunday 23 March 2003 02:34 pm, Andrea Tasso wrote:

> hi all,
> this is a part of my configuration, now from 192.168.2.2 you can do
> surf the internet (I have default ipmask on 192.168.2.1, iptable
> based). the router I do not want to use it to do this stuffs, but the
> 192.168.2.1 server is what I want to use, with iptables, hopefully.

> child PC |       |                       |    | adsl                  
> | wlan0   |       |  wlan0 server eth0    |    | router               

It's generally believed to be a bad idea to post your complete firewall 
rules and your public IP to the list.  All posts to this list eventually 
find themselves on a public web page indexed by search engines.


> I want my child on 192.168.2.2 to be able to connect to a limited list
> of web sites (or IPs), say
> 209.10.154.66
> 192.25.206.10
> 63.70.47.55

> On eth1 of server there is another net 192.168.1.0 (the server is
> 192.168.1.1 and the other is 192.168.1.0) I want to keep to be able to
> do everything

> any example for me ?

This is not the best way to handle this, it really shouldn't be a 
firewall solution.  Filtering in a proxy would be more appropriate.  If 
the child in question has their own computer, and it runs windows, you 
can enable filtering in Internet Exploiter and create an 'approved' list 
there, which will require a password to bypass or add to.  But as far as 
restricting via netfilter this should do what you ask:

iptables -N KidFilter
iptables -A FORWARD -s 192.168.2.2 -p tcp --dport 80 -j KidFilter
iptables -A FORWARD -s 192.168.2.2 -p tcp --dport 80 -j REJECT  \ 
--reject-with icmp-host-prohibited
iptables -A KidFilter -d 209.10.154.66 -j ACCEPT

etc.  You can also use the URL in a rule, like:
iptables -A KidFilter -d www.mamamedia.com -j ACCEPT

If you want to get fancier, you can keep a list of approved IPs (or URLs) 
somewhere, like /usr/etc/KidFilterIPs, then add those from within a 
firewall script with this loop:

for ip in $(cat /usr/etc/KidFilterIPs | grep -v #); do /sbin/iptables -A 
KidFilter -d $ip -j ACCEPT; done

the "grep -v #" will match any line in the file that does NOT have a # in 
it.  This means you have to have each IP or URL on a separate line, and 
you can insert comment lines in the list simply by having a # somewhere 
in the line, traditionally the first character.

If you go with this you'll need to ensure that /usr/etc/KidFilterIPs is 
readable by root at least.


> and this iptables-save

Do you use iptables-load and iptables-save each time, or just to generate 
this listing?  If you use it all the time, then the above approach would 
still work, but obviously you wouldn't have a script you could place the 
mentioned loop in...


> -A FORWARD -s 192.168.2.0/255.255.255.0 -i wlan0 -o eth0 -j ACCEPT

Just make sure that the rules for this specific computer are reached 
before this rule here.  You want to filter 192.168.2.2 first, ACCEPTing 
what is acceptable, REJECTing what you don't want to permit, THEN the 
rest of 192.168.2.0/24 will still be handled by this rule.  If 
connections from 192.168.2.2 hit this rule first, they will always get 
through.


> andrea@tasso.info

j




  parent reply	other threads:[~2003-03-24  8:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-23 19:34 help to build a small firewall for a child Andrea Tasso
2003-03-24  8:16 ` Joel Newkirk
2003-03-24  8:34 ` Joel Newkirk [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-03-24  8:58 Joel Newkirk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200303240334.57004.newkirk@newkirk.us \
    --to=newkirk@newkirk.us \
    --cc=netfilter@lists.netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox