iptables syntax

This is a discussion on iptables syntax within the Linux Networking forums, part of the Linux Forums category; I want to drop new connections from any host except two. Previously I was accepting from one address range as ...


Go Back   Usenet Forums > Linux Forums > Linux Networking

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-24-2003
Matt
 
Posts: n/a
Default iptables syntax

I want to drop new connections from any host except two. Previously I was
accepting from one address range as follows (I've changed the range to a
private one for this post):

iptables -A INPUT -m state --state NEW -i eth0 -j DROP \! -s 172.16.4.0/24

How do I change it so that it drops any new connections except those from
172.16.4.0/24 or 172.16.200.0/24?

Cheers

M


Reply With Quote
  #2 (permalink)  
Old 09-24-2003
Horst Knobloch
 
Posts: n/a
Default Re: iptables syntax

Matt <spam@fritters.com> wrote:

> I want to drop new connections from any host except two. Previously I
> was accepting from one address range as follows (I've changed the range
> to a private one for this post):
>
> iptables -A INPUT -m state --state NEW -i eth0 -j DROP \! -s
> 172.16.4.0/24


I guess this should read "... -j DROP -s \! 172.16.4.0/24"


>
> How do I change it so that it drops any new connections except those from
> 172.16.4.0/24 or 172.16.200.0/24?


iptables -A INPUT -m state --state NEW -i eth0 \
--src 172.16.4.0/24 -j ACCEPT
iptables -A INPUT -m state --state NEW -i eth0 \
--src 172.16.200.0/24 -j ACCEPT
iptables -A INPUT -m state --state NEW -i eth0 -j DROP


Ciao, Horst
--
»When pings go wrong (It hurts me too)« E.Clapton/E.James/P.Tscharn
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:32 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0