Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Gary Renshaw <gary@trilunar.ca>
To: netfilter@vger.kernel.org
Subject: SNAT spoofing problem
Date: Wed, 07 May 2008 11:56:07 -0600	[thread overview]
Message-ID: <4821ED37.3020201@trilunar.ca> (raw)

Greetings,

I am trying to get a host to reject pings with an ICMP host-unreachable 
message so that it looks like the host doesn't exist.  This is easy and 
works nicely.

The problem is that I'd like to use SNAT to spoof the source address so 
that the ICMP looks like it is coming from the network's gateway, not 
the stealthy host.  This isn't working the way I expected.

I've set up a very simple test rig for this.

192.168.1.1 (GATEWAY) <-----> 192.168.1.2 (STEALTH)
                          |
                          \--> 192.168.1.3 (WORKSTATION)

The stealth host is running a very simple "firewall" whose only purpose 
is to block pings and respond with a host-unreachable alleging to be 
from the gateway:

iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -F -t nat
iptables -F -t filter
iptables -X

iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

iptables -A OUTPUT -o eth0 -j ACCEPT

iptables -t nat -A POSTROUTING -o eth0 -p icmp --icmp-type \ 
host-unreachable -j SNAT --to 192.168.1.1

iptables -A INPUT -i eth0 -p icmp --icmp-type echo-request \
-j REJECT --reject-with icmp-host-unreachable

iptables -A INPUT -i eth0 -p all -j ACCEPT

 From STEALTH I can ping anywhere (good).  From WORKSTATION I can ping 
anywhere except STEALTH which returns "host unreachable" (good) BUT the 
message is reported as coming from 192.168.1.2 (bad).  I've looked at 
the packets in detail using wireshark and they really do say that they 
are coming from STEALTH instead of GATEWAY.

It looks like the SNAT is doing nothing at all.  What am I missing?

Thanks,
Gary
-- 
==============================================
Trilunar Consulting    http://www.trilunar.ca/
==============================================

             reply	other threads:[~2008-05-07 17:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-07 17:56 Gary Renshaw [this message]
2008-05-07 19:02 ` SNAT spoofing problem Gáspár Lajos
2008-05-07 19:55   ` Gary Renshaw
2008-05-07 21:12 ` Josh Cepek

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=4821ED37.3020201@trilunar.ca \
    --to=gary@trilunar.ca \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox