From: "Oriol Magrané" <omagrane@mediapro.es>
To: netfilter@lists.netfilter.org
Subject: Newbie question about nat
Date: Fri, 30 Apr 2004 20:20:11 +0200 [thread overview]
Message-ID: <004901c42edf$c73c77b0$a704a8c0@mpro4167> (raw)
[-- Attachment #1: Type: text/plain, Size: 3003 bytes --]
Hello!
I'm trying to set up a firewall with two ethernets to be installed between the internet and a pool of servers.
The setup is as follows:
In the firewall:
-eth0 with public ip 'a.b.c.d', connected to the internet
-eth1 with private ip 192.168.1.1, connected to a private class C subnet
In the internal server 1 (web server):
-eth0 with private ip 192.168.1.100, connected to the subnet above.
I have some public ips available (a.b.c.e, a.b.c.f, a.b.c.g,...) so now I want to map the external ip 'a.b.c.e' with the internal ip '192.168.1.100' .
So in the firewall I do:
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -d a.b.c.e -j DNAT --to 192.168.1.100
iptables -t nat -A POSTROUTING -s 192.168.1.100 -j SNAT --to a.b.c.e
This should effectively
-change destination from a.b.c.e to 192.168.1.100 for packets entering the firewall
-and change source from 192.168.1.100 to a.b.c.e for packets leaving the firewall
Now, if I ping the public address of the internal server 1 (a.b.c.e) from the internet, each packet should traverse the firewall like this:
1. @internet: source=w.x.y.z, destination=a.b.c.e
2. @firewall-prerouting: source=w.x.y.z, destination=192.168.1.100 (destination changed by nat rule 1)
3. @firewall-postrouting: source=w.x.y.z, destination=192.168.1.100 (no changes)
4. @internal_server_1: source=w.x.y.z, destination=192.168.1.100 (so the packet reaches the target)
and then, when the internal server bounces the ping:
1. @internal_server_1: source=192.168.1.100, destination=w.x.y.z
2. @firewall-prerouting: source=192.168.1.100, destination=w.x.y.z (no changes)
3. @firewall-postrouting: source=a.b.c.e, destination=w.x.y.z (source changed by nat rule 2)
4. @internet: source=a.b.c.e, destination=w.x.y.z (so the packet reaches the target)
But this won't work, because the firewall doesn't know it must process packets with destination ips other than its own ip (a.b.c.e, a.b.c.f, etc...), and my ISP doesn't know which machine must deliver these packets to.
So the question is: how can I make the firewall to process the packets with destinations a.b.c.e, a.b.c.f, etc.?
The only solution I've found is to define an ip alias in the firewall itself so that eth0:1 will respond to the external ip a.b.c.e
Thus when the router of my ISP asks "who has ip a.b.c.e?", the firewall will answer "me" and it will process the packet and deliver it to the internal server 1.
But this solution means defining an alias for every external ip I want to firewall. So if I have eight servers firewalled I will need eight ip alias in the firewall.
Is this the right way to do it? Or there is a cleaner/easier/better method to achieve the same?
Thank you very much in advance,
Oriol
Barcelona
[-- Attachment #2: Type: text/html, Size: 6726 bytes --]
next reply other threads:[~2004-04-30 18:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-30 18:20 Oriol Magrané [this message]
2004-04-30 18:37 ` Newbie question about nat Antony Stone
2004-05-03 15:33 ` Oriol Magrané
2004-05-03 15:54 ` Antony Stone
2004-05-04 15:55 ` Oriol Magrané
2004-05-04 16:43 ` Antony Stone
2004-05-01 12:59 ` Alexis
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='004901c42edf$c73c77b0$a704a8c0@mpro4167' \
--to=omagrane@mediapro.es \
--cc=netfilter@lists.netfilter.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