Linux Netfilter discussions
 help / color / mirror / Atom feed
* not ip address
@ 2009-03-25  5:55 Mihamina Rakotomandimby (R12y)
  2009-03-25  6:52 ` lists
  0 siblings, 1 reply; 2+ messages in thread
From: Mihamina Rakotomandimby (R12y) @ 2009-03-25  5:55 UTC (permalink / raw)
  To: netfilter

Hi all
I would like to write this sentence in iptables rule:
  "REJECT everything having port #443 (httpS) as destination except
   if the IP address that query it are one of 192.168.0.18 or 192.168.0.50"

I'd like to forbid httpS/443 traffic except for those two IP addresses.

I made:

$IPT -t nat -A PREROUTING  ! --source 192.168.0.50  \
      -p tcp --dport 443 -j REJECT

and

$IPT -t nat -A PREROUTING  --source ! 192.168.0.50  \
      -p tcp --dport 443 -j REJECT

But they are all bad syntax.

Would you please help me to find my mistake?
I'm running iptables v1.4.0

-- 
                              Chef de projet chez Vectoris
                                  Phone: +261 33 11 207 36
System: xUbuntu 8.10 with almost all from package install
    http://www.google.com/search?q=mihamina+rakotomandimby

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: not ip address
  2009-03-25  5:55 not ip address Mihamina Rakotomandimby (R12y)
@ 2009-03-25  6:52 ` lists
  0 siblings, 0 replies; 2+ messages in thread
From: lists @ 2009-03-25  6:52 UTC (permalink / raw)
  To: Netfilter

> Hi all
> I would like to write this sentence in iptables rule:
>   "REJECT everything having port #443 (httpS) as destination except
>    if the IP address that query it are one of 192.168.0.18 or
> 192.168.0.50"
> 
> I'd like to forbid httpS/443 traffic except for those two IP
> addresses.
> 
> I made:
> 
> $IPT -t nat -A PREROUTING  ! --source 192.168.0.50  \
>       -p tcp --dport 443 -j REJECT
> 
> and
> 
> $IPT -t nat -A PREROUTING  --source ! 192.168.0.50  \
>       -p tcp --dport 443 -j REJECT
> 
> But they are all bad syntax.

$ man iptables

[...]
This target is only valid in the INPUT, FORWARD and OUTPUT chains,
and user-defined chains which are only called from those chains.
[...]

Also, use the filter table for filtering.

$ipt -A INPUT -s 192.168.0.18 -p tcp --dport 443 -j ACCEPT
$ipt -A INPUT -s 192.168.0.50 -p tcp --dport 443 -j ACCEPT
$ipt -A INPUT -p tcp --dport 443 -j REJECT


Grts,
Rob



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-03-25  6:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-25  5:55 not ip address Mihamina Rakotomandimby (R12y)
2009-03-25  6:52 ` lists

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox