討論過程很精彩.最后得出的結論. platinum 的總結...
轉platinum 的總結:http://blog.platinum.net.cn/index.php?op=ViewArticle&articleId=59&blogId=1
分析過程見地址
http://bbs.chinaunix.net/forum/viewtopic.php?show_type=new&p=3547010#3547010
# echo "200 DIANXIN" >> /etc/iproute2/rt_table(這個是添加到文件,執行一次即可)
# ip route replace default via 222.168.1.2 table DIANXIN(replace用來替換默認路由,而不是添加)
# ip rule add fwmark 1 table DIANXIN(這個注意順序,用ip rule可以查看)
# iptables -t nat -F
# iptables -t mangle -F
# iptables -t mangle -A PREROUTING -i eth0 -s 192.168.0.0/24 -d 222.222.5.0/15 -j MARK --set-mark 1
# iptables -t mangle -A PREROUTING -i eth0 -s 192.168.0.0/24 -d 222.240.0.0/13 -j MARK --set-mark 1
# iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -d 222.222.5.0/15 -j SNAT --to $DIANXIN
# iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -d 222.240.0.0/13 -j SNAT --to $DIANXIN
# iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j SNAT --to $接網通線路網卡的地址
# ip route flush cache
這樣的結果,是訪問222.222.5.0/15和222.240.0.0/13走電信網卡、電信路由,偽裝成電信出口地址,其他默認網通
參考文檔:
http://iptables-tutorial.frozentux.net/cn/iptables-tutorial-cn-1.1.19.html
http://www.linuxaid.com.cn/engineer/ideal/article/policy_pouting.htm
http://bbs.chinaunix.net/forum/viewtopic.php?t=304033&highlight=platinum