- 論壇徽章:
- 0
|
5可用積分
實際測試的服務(wù)器采用debian6(內(nèi)核2.6.32)
配置如下:
eth0:外網(wǎng)1,接口IP:10.0.1.2/24 網(wǎng)關(guān):10.0.1.1
eth1:外網(wǎng)2,接口IP:10.0.2.2/24 網(wǎng)關(guān):10.0.2.1
eth2:內(nèi)網(wǎng),接口IP:192.168.10.0/24
內(nèi)網(wǎng)測試PC ,IP:192.168.10.120 通過交換機連接到eth2
設(shè)置iptables:對內(nèi)網(wǎng)IP 192.168.10.120 打標(biāo)簽1
iptables -t mangle -A PREROUTING -s 192.168.10.120 -j MARK --set-mark 0x1
設(shè)置nat:
iptables -t nat -A POSTROUTING -s 192.168.10.0/24 -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 192.168.10.0/24 -o eth1 -j MASQUERADE
設(shè)置兩個策略路由表table10和table20:
ip route add default via 10.0.1.1 table 10
ip route add 192.168.10.0/24 dev eth2 table 10
ip route add default via 10.0.2.1 table 20
ip route add 192.168.10.0/24 dev eth2 table 20
設(shè)置策略路由規(guī)則:、標(biāo)志位1的走出口eth0
/bin/ip rule add fwmark 1 priority 100 table 10
通過以上配置后發(fā)現(xiàn)無法上網(wǎng),tcpdump顯示返回數(shù)據(jù)包無法進(jìn)行nat轉(zhuǎn)換!
例如 在PC 上 ping 218.201.25.131
在eth2 上只能抓到 源地址為192.168.10.120 目的地址為218.201.25.131 的request 包 沒有reply包
在eth0 上可以抓到 源地址為10.0.1.2 目的地址為218.201.25.131 的request 包 和 源地址為218.201.25.131 目的地址為10.0.1.2 的reply 包 |
最佳答案
查看完整內(nèi)容
檢查一下conntrack,按理說conntrack會把返回報文的目的ip改成內(nèi)網(wǎng)ip的(關(guān)注一下應(yīng)答方向的的counter是不是在增加)。同時檢查一下ip route cache,對應(yīng)答報文(注意是dnat后的,即目的ip已被修改為內(nèi)網(wǎng)ip)的路由是不是eth0?會不會是反向路由檢查的限制(檢查一下接口的rp_filter配置)?對于dnat之后的應(yīng)答報文(來自eth0)218.201.25.131 -> 192.160.10.120,如果rp_filter開啟,會內(nèi)部檢查一下,逆向的報文(192.160.10.120- ...
|