I have several ip addresses, X.Y.Z.A - X.Y.Z.D, in one interface (eth1)

X.Y.Z.A is my gateway, with NAT. This works.

I want to access one computer in my LAN (eth0) (Q.W.E.R) from outside, from the X.Y.Z.B ip.

I tried the following rules:

iptables -t NAT -A PREROUTING -d X.Y.Z.B -j DNAT --to-destination Q.W.E.R
iptables -t NAT -A POSTROUTING -s Q.W.E.R -j SNAT --to-source X.Y.Z.B

with no success. Opening a browser and typing X.Y.Z.B still shows my firewalls web server, and RDP times out.

Can anybody tell me, how to do this?

link|improve this question
feedback

1 Answer

up vote 1 down vote accepted

exclude Q.W.E.R from the previous NAT rule i.e. your general nat rule should be AFTER those two above (or put them with -I )

link|improve this answer
You mean iptables -t NAT -A PREROUTING -d X.Y.Z.B -j DNAT --to-destination Q.W.E.R iptables -t NAT -A POSTROUTING -s Q.W.E.R -j SNAT --to-source X.Y.Z.B iptables -t nat -A postrouting -o $wan_iface -j SNAT --to $WAN_IP ? still not good... – dutow Oct 11 '09 at 21:22
sorry, it works, just not from the lan. – dutow Oct 11 '09 at 22:18
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.