From: Grant Taylor <gtaylor@riverviewtech.net>
To: "Philipp Päper" <piepre@gmx.de>
Cc: netfilter@lists.netfilter.org
Subject: Re: nat of all local dns-request to my own server
Date: Sun, 10 Apr 2005 14:59:21 -0500 [thread overview]
Message-ID: <42598599.2070502@riverviewtech.net> (raw)
In-Reply-To: <1113137280.2857.20.camel@piepre-debian.klo>
What you are asking for sounds simple enough. Though as I read your script below I see a few things that differ from what I would do. I would use something along these lines:
EXT=eht1
EXT_IP=193.x.x.251
EXT_NET=193.x.x.0/24
DMZ=eth2
DMZ_IP=10.0.0.1
DMZ_NET=10.0.0.1/30
INT=eth0
INT_IP=192.168.112.1
INT_NET=192.168.112.0/24
SERVER_DMZ=10.0.0.2
iptables -t nat -A PREROUTING -i $INT -s $INT_NET -d $INT_IP -p tcp --dport 53 -j DNAT --to-destination $SERVER_DMZ
iptables -t nat -A PREROUTING -i $INT -s $INT_NET -d $INT_IP -p udp --dport 53 -j DNAT --to-destination $SERVER_DMZ
iptables -t nat -A POSTROUTING -o $DMZ -s $INT_NET -d $SERVER_DMZ -p tcp --dport 53 -j SNAT --to-source $DMZ_IP
iptables -t nat -A POSTROUTING -o $DMZ -s $INT_NET -d $SERVER_DMZ -p udp --dport 53 -j SNAT --to-source $DMZ_IP
iptables -t filter -A FORWARD -i $INT -o $DMZ -s $INT_NET -d $SERVER_DMZ -p tcp -m state --state NEW -j ACCEPT
iptables -t filter -A FORWARD -i $DMZ -o $INT -s $SERVER_DMZ -d $INT_NET -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t filter -A FORWARD -i $ING -o $DMZ -s $IMT_NET -d $SERVER_DMZ -p udp -j ACCEPT
iptables -t filter -A FORWARD -i $DMZ -o $INT -s $SERVER_DMZ -d $INT_NET -p udp -j ACCEPT
Something to keep in mind is that UDP does not have states like TCP does so you can't do a statefull match against it. What this will effectively do is take any TCP and UDP traffic coming in the $INT interface destined to the $INT_IP on port 53 DNAT it to the $SERVER_DMZ and last but not least SNATing the traffic as to appear as if it is coming from the firewall + router its self to the new server $SERVER_DMZ. The reason you want the traffic to appear as if it is coming from the firewall its self is because if it responds directly to the clients making the DNS query the traffic will appear to be coming from an IP that the client's have not been communicating with. Keep in mind that the clients are sending the DNS query to $INT_IP and they would get a response from $SERVER_DMZ which are not the same.
Grant. . . .
> networkplan:
>
> internet
> |
> |
> router ---- server (DNS + HTTP + EMail)
> |
> |
> intranet
>
> router: intern: eth0 - 192.168.112.1, extern: eth1 - 193.x.x.251, dmz:
> eth2 - 10.0.0.1
> server: eth0: 10.0.0.2
>
> here are the rule i tried the last time:
>
> EXT=eht1
> EXT_IP=193.x.x.251
> EXT_NET=193.x.x.0/24
> DMZ=eth2
> DMZ_IP=10.0.0.1
> DMZ_NET=10.0.0.1/30
> INT=eth0
> INT_IP=192.168.112.1
> INT_NET=192.168.112.0/24
>
> SERVER_DMZ=10.0.0.2
>
> iptables -t nat -A PREROUTING -i $INT -p tcp --dport 53 -j DNAT --to-destination $SERVER_DMZ
> iptables -t nat -A POSTROUTING -o $INT -s $SERVER_DMZ -p tcp --dport 53 -j SNAT --to-source $INT_IP
> iptables -A FORWARD -i $INT -m state --state NEW -p tcp -d $SERVER_DMZ --dport 53 -j ACCEPT
> iptables -t nat -A PREROUTING -i $INT -p udp --dport 53 -j DNAT --to-destination $SERVER_DMZ
> iptables -t nat -A POSTROUTING -o $INT -s $SERVER_DMZ -p udp --dport 53 -j SNAT --to-source $INT_IP
> iptables -A FORWARD -i $INT -m state --state NEW -p udp -d $SERVER_DMZ --dport 53 -j ACCEPT
prev parent reply other threads:[~2005-04-10 19:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-10 12:48 nat of all local dns-request to my own server Philipp Päper
2005-04-10 19:59 ` Grant Taylor [this message]
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=42598599.2070502@riverviewtech.net \
--to=gtaylor@riverviewtech.net \
--cc=netfilter@lists.netfilter.org \
--cc=piepre@gmx.de \
/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.