From: "Milan Pavlovic" Subject: DNAT 'problem' Date: Fri, 14 Jun 2002 02:51:59 +0200 Sender: netfilter-admin@lists.samba.org Message-ID: <008201c2133d$b0978cd0$1e03a8c0@blickompanija.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_007F_01C2134E.73EF88D0" Return-path: Errors-To: netfilter-admin@lists.samba.org List-Help: List-Post: List-Subscribe: , List-Id: List-Unsubscribe: , List-Archive: To: netfilter@lists.samba.org This is a multi-part message in MIME format. ------=_NextPart_000_007F_01C2134E.73EF88D0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello, This is a little problem I can't solve for now; so I'm asking for help = if something simple and obvious I have missed to do... Well, on the x.x.x.x box, for locally generated traffic, there should = be dst address changed for every packet going for y.y.y.y:25 (tcp) to = z.z.z.z:25.=20 And i did: #> iptables -I OUTPUT -t nat -p tcp -d y.y.y.y --dport 25 -j DNAT --to = z.z.z.z:25 Now, when I try if this is working, there is no connection made: #> telnet y.y.y.y 25 =20 Trying y.y.y.y .... On the other hand, tethereal on the output interface (eth5) shows that = first packet goes OK (dst changed, SYN flag set), 2nd get back also good = (SYN,ACK, to the same source port), but the 3rd one, going out of box, = put RST flag, and new source port........ =20 1. X.X.X.X -> Z.Z.Z.Z TCP 50384 > 25 [SYN] Seq=3D1195885807 Ack=3D0 = Win=3D5840 Len=3D0 2. Z.Z.Z.Z -> X.X.X.X TCP 25 > 50384 [SYN, ACK] Seq=3D2431219150 = Ack=3D1195885808 Win=3D8760 Len=3D0 3. X.X.X.X -> Z.Z.Z.Z TCP 1037 > 25 [RST] Seq=3D1195885808 Ack=3D0 = Win=3D0 Len=3D0 ^^^^ ^^^^^ 4. Z.Z.Z.Z -> X.X.X.X TCP 25 > 50384 [SYN, ACK] Seq=3D2431219150 = Ack=3D1195885808 Win=3D8760 Len=3D0 5. X.X.X.X -> Z.Z.Z.Z TCP 1037 > 25 [RST] Seq=3D1195885808 Ack=3D0 = Win=3D0 Len=3D0 6. X.X.X.X -> Z.Z.Z.ZTCP 50384 > 25 [SYN] Seq=3D1195885807 Ack=3D0 = Win=3D5840 Len=3D0 7. Z.Z.Z.Z -> X.X.X.X TCP 25 > 50384 [ACK] Seq=3D2431219151 = Ack=3D1195885808 Win=3D8760 Len=3D0 8. X.X.X.X -> Z.Z.Z.ZTCP 1037 > 25 [RST] Seq=3D1195885808 Ack=3D0 = Win=3D0 Len=3D0 9. Z.Z.Z.Z -> X.X.X.XTCP 25 > 50384 [SYN, ACK] Seq=3D2431219150 = Ack=3D1195885808 Win=3D8760 Len=3D0=20 10. X.X.X.X -> Z.Z.Z.ZTCP 1037 > 25 [RST] Seq=3D1195885808 Ack=3D0 = Win=3D0 Len=3D0 ... ... By the way,this box has several interfaces, among which one is on local = network eth0 (192.168.3.3), and other, eth5 (x.x.x.x) is on ISP's LAN, = so SNAT is done: #> iptables -I POSTROUTING -t nat -i eth0 -o eth5 -d x.x.x.0/24 -j SNAT = --to x.x.x.x=20 Also, (static) routing is ok... So how can I transfer traffic destined to one mail server to other one, = without changing DNS data for specific domain (ie MX record)?? ------=_NextPart_000_007F_01C2134E.73EF88D0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hello,
This is a little problem I can't solve = for now; so=20 I'm asking for help if something simple and obvious I have missed to=20 do...
 
Well, on the x.x.x.x  box, = for locally=20 generated traffic, there should be dst address changed for=20 every  packet going for y.y.y.y:25 (tcp) to=20 z.z.z.z:25. 
And i did:
 
#> iptables -I OUTPUT -t nat -p tcp = -d=20 y.y.y.y --dport 25 -j DNAT --to z.z.z.z:25
 
Now, when I try if this is = working, there is=20 no connection made:
#> telnet y.y.y.y=20 25   
Trying y.y.y.y ....
 
 
On the other hand, tethereal on the = output=20 interface (eth5) shows that first packet goes OK (dst changed, SYN = flag=20 set), 2nd get back also good (SYN,ACK, to the same source port), but the = 3rd=20 one, going out of box, put RST flag, and new source = port........
 
1.  = X.X.X.X -> Z.Z.Z.Z TCP 50384=20 > 25 [SYN] Seq=3D1195885807 Ack=3D0 Win=3D5840 Len=3D0
2.  Z.Z.Z.Z -> X.X.X.X TCP 25 = > 50384=20 [SYN, ACK] Seq=3D2431219150 Ack=3D1195885808 Win=3D8760 = Len=3D0
3.  X.X.X.X -> Z.Z.Z.Z TCP 1037 = > 25=20 [RST] Seq=3D1195885808 Ack=3D0 Win=3D0 Len=3D0
          &nbs= p;            = ;            =     ^^^^       &nb= sp;  =20 ^^^^^
4.  Z.Z.Z.Z -> X.X.X.X TCP 25 = > 50384=20 [SYN, ACK] Seq=3D2431219150 Ack=3D1195885808 Win=3D8760 = Len=3D0
5.  X.X.X.X -> Z.Z.Z.Z TCP 1037 = > 25=20 [RST] Seq=3D1195885808 Ack=3D0 Win=3D0 Len=3D0
6.  X.X.X.X -> = Z.Z.Z.ZTCP=20 50384 > 25 [SYN] Seq=3D1195885807 Ack=3D0 Win=3D5840 = Len=3D0
7.  Z.Z.Z.Z=20 -> X.X.X.X TCP 25 > 50384 [ACK] Seq=3D2431219151 Ack=3D1195885808 = Win=3D8760=20 Len=3D0
8.  X.X.X.X -> Z.Z.Z.ZTCP 1037 > 25 [RST] = Seq=3D1195885808=20 Ack=3D0 Win=3D0 Len=3D0
9.  Z.Z.Z.Z -> X.X.X.XTCP 25 > = 50384 [SYN, ACK]=20 Seq=3D2431219150 Ack=3D1195885808 Win=3D8760 Len=3D0
10. X.X.X.X -> Z.Z.Z.ZTCP 1037 > = 25 [RST]=20 Seq=3D1195885808 Ack=3D0 Win=3D0 Len=3D0
...
...
 
By the way,this box=20 has several interfaces, among which one is on local network eth0 = (192.168.3.3),=20 and  other, eth5 (x.x.x.x) is on ISP's LAN, so SNAT is=20 done:
 
#> iptables -I POSTROUTING -t = nat -i eth0=20 -o eth5 -d x.x.x.0/24 -j SNAT --to x.x.x.x 
 
Also, (static) routing is = ok...
 
So how can I transfer = traffic destined=20 to one mail server to other one, without changing DNS data for = specific=20 domain (ie MX record)??
------=_NextPart_000_007F_01C2134E.73EF88D0--