Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

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 )

share|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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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