All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Killock <lists@killock.net>
To: "André Paulsberg-Csibi (IBM Consultant)"
	<Andre.Paulsberg-Csibi@evry.com>
Cc: "Neal P. Murphy" <neal.p.murphy@alum.wpi.edu>,
	netfilter@vger.kernel.org, netfilter-owner@vger.kernel.org
Subject: RE: Iptables Reject with TCP Reset
Date: Wed, 11 Jan 2017 10:34:48 +0000	[thread overview]
Message-ID: <b2b4cd74a6a03e24947c05646f5e8e76@killock.net> (raw)
In-Reply-To: <e5943affc23440f3bcb33662ba18a82f@CCDEX021.corp.corpcommon.com>

On 2017-01-11 10:21, André Paulsberg-Csibi wrote:
> From what you sent me directly , you also allowed this in the OUTPUT
> chain which makes no sense to me ...
> ... but it maybe that the rules set has somehow been "broken" and it
> is now causing un-intended packet handling .

You might need INPUT, OUTPUT & FORWARD policies all to be 'DROP' for 
this behaviour.

I reproduced this at home using the below script (now corrected for 
copy/paste errors)

It's very basic, and should allow you to telnet from an internal host to 
the allowed HTTP site but refuse all other port 80's

I used tcpdump on the firewall to monitor the LAN interface.

--------------------------------------------------

A='/sbin/iptables'
EXIF='ppp0'
LANIF='eth1'

#Clear
$A -F
$A -F INPUT
$A -F OUTPUT
$A -F FORWARD
$A -F -t mangle
$A -F -t nat
$A -X

#Setup policies
$A -P INPUT DROP
$A -P OUTPUT DROP
$A -P FORWARD DROP

echo "1" > /proc/sys/net/ipv4/ip_forward

# Some basics
# Accept loopback interface
$A -A INPUT -i lo -j ACCEPT
$A -A OUTPUT -o lo -j ACCEPT

# SSH from LAN
$A -A INPUT -i $LANIF -p tcp --dport 22 -j ACCEPT

#general NAT
$A -t nat -A POSTROUTING -o $EXIF -j MASQUERADE

#General State Matching
$A -A OUTPUT -m state --state ESTABLISHED -j ACCEPT
$A -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT

#Allowed HTTP/HTTPS Sites
#bbc
$A -A FORWARD -i $LANIF -o $EXIF -d 212.58.244.22 -p tcp -m multiport
--dports '80,443' -j ACCEPT

#Send RST to LAN for all other 80/443 connections
$A -A FORWARD -i $LANIF -p tcp -m multiport --dports '80,443' -j REJECT
--reject-with tcp-reset


--------------------------


Matt

  reply	other threads:[~2017-01-11 10:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-06 15:19 Iptables Reject with TCP Reset Matt Killock
2017-01-06 16:09 ` Noel Kuntze
2017-01-06 16:28   ` Matt Killock
2017-01-06 16:35     ` Noel Kuntze
     [not found]       ` <HK2PR0201MB212932A38853DB306E300014E8630@HK2PR0201MB2129.apcprd02.prod.outlook.com>
2017-01-06 17:52         ` Noel Kuntze
2017-01-09 10:45           ` Matt Killock
2017-01-10  7:35             ` André Paulsberg-Csibi (IBM Consultant)
2017-01-10 10:09               ` Matt Killock
2017-01-10 11:41                 ` André Paulsberg-Csibi (IBM Consultant)
2017-01-10 18:32                 ` Neal P. Murphy
2017-01-10 19:29                   ` Matt Killock
2017-01-11 10:21                     ` André Paulsberg-Csibi (IBM Consultant)
2017-01-11 10:34                       ` Matt Killock [this message]
2017-01-06 17:30     ` Ethy H. Brito
2017-01-06 23:26     ` Neal P. Murphy
2017-01-06 23:40       ` Noel Kuntze

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=b2b4cd74a6a03e24947c05646f5e8e76@killock.net \
    --to=lists@killock.net \
    --cc=Andre.Paulsberg-Csibi@evry.com \
    --cc=neal.p.murphy@alum.wpi.edu \
    --cc=netfilter-owner@vger.kernel.org \
    --cc=netfilter@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.