NAT LOOPBACK DNAT - Linux

Table of Contents

我有一台Linux ,設定 dhcp 跟 NAT

PCA
Linux <--->
PCB

Linux WAN ip 1.2.3.4
LINUX LAN ip 192.168.1.1
PCA ip 192.168.1.2
PCB ip 192.168.1.3


PCA上面裝了 http server

AP 設定 Port Forward 到 PCA

我希望能從PCB 打 AP的 WAN IP 就能存取 PCA的網頁

1. iptables -t nat -I PREROUTING -i br0 -d 1.2.3.4 -j DNAT --to 192.168.1.2
2. iptables -t nat -I POSTROUTING -s 192.168.1.1/24 -o br0 -d 192.168.1.2 -j SNAT --to 192.168.1.1


iptables -L -vn -t nat 看到 1. pkg 會增加 但是 2.pkg 不會增加

ip_forward 1

請各位指點一下迷津 謝謝


--

All Comments

Tom avatarTom2014-02-21
可能被其它未列出的 iptables rules 擋到了? 我實測沒問題.
Leila avatarLeila2014-02-23
我有把其他 rule清掉了,我這邊用較新的Linux 也是可以XD
Steve avatarSteve2014-02-28
封包應該會直接做 dnat + snat 才對,但做完dnat就消失了
Mason avatarMason2014-02-28
所以出問題的 kernel 是哪個版本?
Irma avatarIrma2014-03-04
其實 NAT loopback 是很久的東西了, 很久前 2.4.2x 就 OK 了,
Candice avatarCandice2014-03-08
後來 2.6.3x 也用過; 這次用 3.5.0 (ubuntu12.04)測也沒問題.