求教各位前輩一個ip mapping的問題
我的環境是
== Internet ==== FireWall =========公司內部私人ip=
Web server------- NAT+
Mail Server-------Proxy(squid) -------公司內部
Ftp Server-------- (192.168.1.0/24)
未來我希望能把 Web Server,Mail Server,Ftp Server都搬到公司內部網路
== Internet ==== FireWall ==============公司內部 私人ip=
NAT+
Internet ----- Proxy ------------------公司內部
(對外ip 210.202.xx.100) (192.168.1.0/24)
(對內ip 192.168.1.254) Web Server(192.168.1.1)
Mail Server
(192.168.1.2)
Ftp Server
(192.168.1.3)
我試過 port Mapping 和 ip Mapping都不行,請問我的作法那邊有問題,
我的做法是
1.先把各個Server 在Internet上的public ip 綁在 Nat Server 對外的網卡上
/sbin/ifconfig eth1:1 210.202.XX.1 broadcast 210.202.XX.XX netmask 255.255.255.240
/sbin/ifconfig eth1:2 210.202.XX.2 broadcast 210.202.XX.XX netmask 255.255.255.240
/sbin/ifconfig eth1:3 210.202.XX.3 broadcast 210.202.XX.XX netmask 255.255.255.240
2.打開 Forward 機制
echo "1" > /proc/sys/net/ipv4/ip_forward
3.使用 DNAT的方式 (先舉 Web Server開始,其中紅色那一行是我後來才加上去的,也不行)
#WebServer Mapping
/sbin/iptables -t nat -A PREROUTING -d 210.202.XX.1 -p tcp --dport 80 -j DNAT --to 192.168.1.1:80
/sbin/iptables -t nat -A POSTROUTING -d 192.168.1.1 -p tcp --dport 80 -j SNAT --to-source 192.168.1.254
4.Web Server 的default Gateway 也有指回 Nat的內部ip 192.168.1.254
5.用別台電腦,使用 Public ip 連 210.202.XX.1 等很久都沒回應
用別台電腦,使用 內部 ip 連 210.202.XX.1 等很久都沒回應
用別台電腦,使用 內部 ip 連 192.168.1.1 (Web Server) ok 可以連線
QA: 1.我不知道是不是我一張網卡綁好幾個ip的問題
2.iptables 做DNAT的方式錯誤
3.請問上面紅色那一行 SNAT的方式,那麼 當 Web Server把訊息回給 gateway , Nat Server 那邊的記錄會把 Source ip 和 destination ip 復原,並將訊息傳給 internet 上,呼叫此網頁的電腦嗎?