public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] Re: IPTables - Going Stateless
       [not found] ` <201305211133.03830.neal.p.murphy@alum.wpi.edu>
@ 2013-05-21 16:01   ` Nick Khamis
  2013-05-21 16:14     ` Alan McKinnon
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Khamis @ 2013-05-21 16:01 UTC (permalink / raw
  To: gentoo-user

For testing purposes I changed the ssh rule to:

-A TCP -p tcp -m tcp --dport 22 -j ACCEPT
-A TCP -p tcp -m tcp -s 0.0.0.0/0 -d 192.168.2.5 --dport 22 -j DROP

And still no go. As mentioned before, everything works fine until I
try to close up the rest of the ports not opened up in the chains
"UDP" and "TCP" stated above:

#echo -e "       - Dropping input TCP and UDP traffic to closed ports"
-A INPUT -i $INTIF1 -p tcp -j REJECT --reject-with tcp-rst
-A INPUT -i $INTIF1 -p udp -j REJECT --reject-with icmp-port-unreachable

#echo -e "       - Dropping output TCP and UDP traffic to closed ports"
-A OUTPUT -o $INTIF1 -p tcp -j REJECT --reject-with tcp-rst
-A OUTPUT -o $INTIF1 -p udp -j REJECT --reject-with icmp-port-unreachable

#echo -e "       - Dropping input traffic to remaining protocols sent
to closed ports"
-A INPUT -i $INTIF1 -j REJECT --reject-with icmp-proto-unreachable

#echo -e "       - Dropping output traffic to remaining protocols sent
to closed ports"
-A OUTPUT -o $INTIF1 -j REJECT --reject-with icmp-proto-unreachable

That is when I cannot SSH over to the server.

N.


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

* Re: [gentoo-user] Re: IPTables - Going Stateless
  2013-05-21 16:01   ` [gentoo-user] Re: IPTables - Going Stateless Nick Khamis
@ 2013-05-21 16:14     ` Alan McKinnon
  0 siblings, 0 replies; 7+ messages in thread
From: Alan McKinnon @ 2013-05-21 16:14 UTC (permalink / raw
  To: gentoo-user

On 21/05/2013 18:01, Nick Khamis wrote:
> For testing purposes I changed the ssh rule to:
> 
> -A TCP -p tcp -m tcp --dport 22 -j ACCEPT
> -A TCP -p tcp -m tcp -s 0.0.0.0/0 -d 192.168.2.5 --dport 22 -j DROP
> 
> And still no go. As mentioned before, everything works fine until I
> try to close up the rest of the ports not opened up in the chains
> "UDP" and "TCP" stated above:
> 
> #echo -e "       - Dropping input TCP and UDP traffic to closed ports"
> -A INPUT -i $INTIF1 -p tcp -j REJECT --reject-with tcp-rst
> -A INPUT -i $INTIF1 -p udp -j REJECT --reject-with icmp-port-unreachable
> 
> #echo -e "       - Dropping output TCP and UDP traffic to closed ports"
> -A OUTPUT -o $INTIF1 -p tcp -j REJECT --reject-with tcp-rst
> -A OUTPUT -o $INTIF1 -p udp -j REJECT --reject-with icmp-port-unreachable
> 
> #echo -e "       - Dropping input traffic to remaining protocols sent
> to closed ports"
> -A INPUT -i $INTIF1 -j REJECT --reject-with icmp-proto-unreachable
> 
> #echo -e "       - Dropping output traffic to remaining protocols sent
> to closed ports"
> -A OUTPUT -o $INTIF1 -j REJECT --reject-with icmp-proto-unreachable
> 
> That is when I cannot SSH over to the server.


Now you are feeling the pain.

Drive to where the router is and fix it on the console then put
conntrack back.



-- 
Alan McKinnon
alan.mckinnon@gmail.com



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

* [gentoo-user] Re: IPTables - Going Stateless
       [not found] <201305211211.53740.neal.p.murphy@alum.wpi.edu>
@ 2013-05-21 16:29 ` Nick Khamis
  2013-05-21 16:53   ` Nick Khamis
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Khamis @ 2013-05-21 16:29 UTC (permalink / raw
  To: neal.p.murphy; +Cc: gentoo-user

On 5/21/13, Neal Murphy <neal.p.murphy@alum.wpi.edu> wrote:
> You still aren't accepting *each* direction. Either accept each direction
> with
> explicit rules or rewrite the rules so they apply to both directions at
> once.
> The former is probably easier to understand months later, even though it is
>
> more verbose.
>
> Mea culpa. I missed the '--dport'; that should be changed to '--sport' in
> one
> of the rules. I adjusted the rule below.
>
> N
>
> On Tuesday, May 21, 2013 11:07:10 AM you wrote:
>> Hello Everyone,
>>
>> #echo -e "       - Accepting SSH Traffic"
>> $IPTABLES -A TCP -p tcp -m tcp -s 192.168.2.0/24 -d 192.168.2.5
>> --dport 22 -j ACCEPT
>> $IPTABLES -A TCP -p tcp -m tcp -s 0.0.0.0/0 -d 192.168.2.5 --dport 22 -j
>> DROP
>>
>> Everything works fine with the REJECT rules commented out, but when
>> included SSH access is blocked out. Not sure why, isn't the sequence
>> correct (i.e., the ACCPET entries before the DROP and REJECT)?
>
> SSH isn't a one-way protocol. I believe you need at least one more rule.
> This:
>     -A TCP -p tcp -m tcp -s 192.168.2.0/24 -d 192.168.2.5 \
>        --dport 22 -j ACCEPT
> only matches packets in one direction. You need to add:
>     -A TCP -p tcp -m tcp -s 192.168.2.5 -d 192.168.2.0/24 \
>        --sport 22 -j ACCEPT
> to accept packets in the other direction.
>
>


That was it!!! Thank you so much. For future searchers to similar problems:


#!/bin/bash
IPTABLES='/sbin/iptables'

#Set interface values
INTIF1='eth0'

#flush rules and delete chains
$IPTABLES -F
$IPTABLES -X

#echo -e "       - Accepting input lo traffic"
$IPTABLES -A INPUT -i lo -j ACCEPT

#echo -e "       - Accepting output lo traffic"
$IPTABLES -A OUTPUT -o lo -j ACCEPT

#echo -e "       - Defined Chains"
$IPTABLES -N TCP
$IPTABLES -N UDP

#echo -e "       - Accepting SSH Traffic"
$IPTABLES -A TCP -p tcp -m tcp -s 192.168.2.0/24 -d 192.168.2.5
--dport 22 -j ACCEPT
$IPTABLES -A TCP -p tcp -m tcp -s 192.168.2.5 --sport 22 -d
192.168.2.0/24 -j ACCEPT
$IPTABLES -A TCP -p tcp -m tcp -s 0.0.0.0/0 -d 192.168.2.5 --dport 22 -j DROP

#echo -e "       - Accepting input TCP and UDP traffic to open ports"
$IPTABLES -A INPUT -i $INTIF1 -p tcp -j TCP
$IPTABLES -A INPUT -i $INTIF1 -p udp -j UDP

#echo -e "       - Accepting output TCP and UDP traffic to open ports"
$IPTABLES -A OUTPUT -o $INTIF1 -p tcp -j TCP
$IPTABLES -A OUTPUT -o $INTIF1 -p udp -j UDP

#echo -e "       - Dropping input TCP and UDP traffic to closed ports"
$IPTABLES -A INPUT -i $INTIF1 -p tcp -j REJECT --reject-with tcp-rst
$IPTABLES -A INPUT -i $INTIF1 -p udp -j REJECT --reject-with
icmp-port-unreachable

#echo -e "       - Dropping output TCP and UDP traffic to closed ports"
$IPTABLES -A OUTPUT -o $INTIF1 -p tcp -j REJECT --reject-with tcp-rst
$IPTABLES -A OUTPUT -o $INTIF1 -p udp -j REJECT --reject-with
icmp-port-unreachable

#echo -e "       - Dropping input traffic to remaining protocols sent
to closed ports"
$IPTABLES -A INPUT -i $INTIF1 -j REJECT --reject-with icmp-proto-unreachable

#echo -e "       - Dropping output traffic to remaining protocols sent
to closed ports"
$IPTABLES -A OUTPUT -o $INTIF1 -j REJECT --reject-with icmp-proto-unreachable


Kind Regards,

Nick.


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

* [gentoo-user] Re: IPTables - Going Stateless
  2013-05-21 16:29 ` Nick Khamis
@ 2013-05-21 16:53   ` Nick Khamis
  2013-05-21 22:41     ` Mike Gilbert
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Khamis @ 2013-05-21 16:53 UTC (permalink / raw
  To: neal.p.murphy; +Cc: gentoo-user

Neal,

As for the --sport flag for OUTPUT, should it not be left arbitrary?
The SSH  daemon should use unprivileged ports between 1024 and 65535.
The only daemon I know thus far that does not is NTP which is
hardwired to 123 both ways.

Thanks Guys,

Nick.


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

* Re: [gentoo-user] Re: IPTables - Going Stateless
  2013-05-21 16:53   ` Nick Khamis
@ 2013-05-21 22:41     ` Mike Gilbert
  2013-05-22  0:16       ` Adam Carter
       [not found]       ` <CAC=wYCEs6rkR5ch4rsumJKj9Kg5e+j_LEr@mail.gmail.com>
  0 siblings, 2 replies; 7+ messages in thread
From: Mike Gilbert @ 2013-05-21 22:41 UTC (permalink / raw
  To: gentoo-user; +Cc: neal.p.murphy

On Tue, May 21, 2013 at 12:53 PM, Nick Khamis <symack@gmail.com> wrote:
> Neal,
>
> As for the --sport flag for OUTPUT, should it not be left arbitrary?
> The SSH  daemon should use unprivileged ports between 1024 and 65535.
> The only daemon I know thus far that does not is NTP which is
> hardwired to 123 both ways.
>

Most daemons send/receive on the same port on the server. The port
used by the /client/ is generally random.

An exception would be an FTP daemon, which uses port 20 for active
mode data connections, but a random port for passive data connections.
FTP is weird like that.


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

* Re: [gentoo-user] Re: IPTables - Going Stateless
  2013-05-21 22:41     ` Mike Gilbert
@ 2013-05-22  0:16       ` Adam Carter
       [not found]       ` <CAC=wYCEs6rkR5ch4rsumJKj9Kg5e+j_LEr@mail.gmail.com>
  1 sibling, 0 replies; 7+ messages in thread
From: Adam Carter @ 2013-05-22  0:16 UTC (permalink / raw
  To: gentoo-user@lists.gentoo.org

[-- Attachment #1: Type: text/plain, Size: 209 bytes --]

Anyone advocating stateless firewalls in 2013 deserves scrutiny. I would be
asking for some evidence there is a performance issue, and that the best
solution to the problem is to turn off stateful inspection.

[-- Attachment #2: Type: text/html, Size: 235 bytes --]

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

* [gentoo-user] Re: IPTables - Going Stateless
       [not found]       ` <CAC=wYCEs6rkR5ch4rsumJKj9Kg5e+j_LEr@mail.gmail.com>
@ 2013-05-22  2:16         ` James
  0 siblings, 0 replies; 7+ messages in thread
From: James @ 2013-05-22  2:16 UTC (permalink / raw
  To: gentoo-user

Adam Carter <adamcarter3 <at> gmail.com> writes:


> Anyone advocating stateless firewalls in 2013 deserves scrutiny. I would 
> be asking for some evidence there is a performance issue, and that the 
> best solution to the problem is to turn off stateful inspection.


There are lots of tools and approaches to security. Here is something
you might want to investigate further: Stateless Firewall Filters:
great for fending off DDOS and such.......

Instead of the maginot wall (firewall router) several different
security devices can be layered in a serial path to perfrom
various and diffent security functions.

Here is a starting point by a fairly reputable routing vendor:

http://www.juniper.net/techpubs/en_US/junos12.2/topics/concept/firewall-filter-overview.html

http://www.juniper.net/techpubs/software/junos-security/junos-security10.3/junos-security-swconfig-interfaces-and-routing/topic-47671.html

http://www.juniper.net/techpubs/en_US/junos/topics/concept/firewall-filter-types.html


James




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

end of thread, other threads:[~2013-05-22  2:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CAGWRaZbwp8jDPxDzHX6g_LkpK74iB6K4GSoU7c_5THDSx1oDmQ@mail.gmail.com>
     [not found] ` <201305211133.03830.neal.p.murphy@alum.wpi.edu>
2013-05-21 16:01   ` [gentoo-user] Re: IPTables - Going Stateless Nick Khamis
2013-05-21 16:14     ` Alan McKinnon
     [not found] <201305211211.53740.neal.p.murphy@alum.wpi.edu>
2013-05-21 16:29 ` Nick Khamis
2013-05-21 16:53   ` Nick Khamis
2013-05-21 22:41     ` Mike Gilbert
2013-05-22  0:16       ` Adam Carter
     [not found]       ` <CAC=wYCEs6rkR5ch4rsumJKj9Kg5e+j_LEr@mail.gmail.com>
2013-05-22  2:16         ` James

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