Gentoo Archives: gentoo-server

From: Christian Parpart <trapni@g.o>
To: gentoo-server@l.g.o
Subject: [gentoo-server] iptables NAT and service move from host to host
Date: Fri, 29 Sep 2006 15:26:10
Message-Id: 200609291723.18328.trapni@gentoo.org
1 Hi,
2
3 we're about to move some services from an old host to a newer one,
4 however, we want to keep up the old host for a week after the migration, so,
5 that everyone may choose their own good time to switch their IP's in their
6 local configs.
7
8 that is, I want to all IP packets incoming at $old_ip to be redirected to
9 $new_ip via iptables.
10
11 unfortunately, in my little test, that didn't work '(
12
13 Executing the following on the $old_ip's host.
14
15 $ old_ip=public.ip.1
16 $ new_ip=public.ip.2
17
18 $ iptables -t nat -A PREROUTING -p tcp --dport 81 \
19 -d $old_ip -i eth0 -j DNAT --to-destination $new_ip:80
20 $ iptables -t nat -A POSTROUTING -p tcp --sport 80 -\
21 s $new_ip -o eth0 -j SNAT --to-source $old_ip:81
22
23 now, a $(telnet $old_ip:81) shall be equivalent to $(telnet $new_ip:80).
24 but it seems that no packet is reaching the $new_ip's host.
25
26 So has anybody a nice hint for me where I ran into what pitfall?
27
28 Thanks in advance,
29 Christian Parpart.

Replies

Subject Author
Re: [gentoo-server] iptables NAT and service move from host to host Kalin KOZHUHAROV <kalin@××××××××.net>