iptables加上静态路由实现代理服务问题
本帖最后由 xuyao2032011 于 2011-06-13 13:45 编辑
说明:
如图所示,所有的环境都是在虚拟机环境下做的,所有的网卡都是桥接模式。
proxy2和gad1是2台linux虚拟机,之间配置tunnel隧道。配置信息如下:
proxy2:
source /root/.bash_profile
/sbin/service tunnel_gad1 start (运行隧道配置)
/sbin/iptables -t nat -A PREROUTING -i eth0 -d 192.168.1.1 -p tcp --dport 80 -j DNAT --to 192.168.2.2:80
/sbin/route add -host 192.168.2.2 gw 192.168.237.25
/etc/init.d/httpd start
隧道脚本:
#!/bin/bash
REMOTEIP=10.253.0.101
LOCALIP=10.253.0.100
#REMOTENET=192.168.80.0/24
TUNDEV=gad1
TUNIP=192.168.237.26
NETMASK=255.255.255.252
start()
{
modprobe ipip
iptunnel add ${TUNDEV} mode ipip remote ${REMOTEIP} local ${LOCALIP}
ifconfig ${TUNDEV} ${TUNIP} netmask ${NETMASK}
# route add -net ${REMOTENET} gw ${GATEWAY} dev ${TUNDEV}
}
stop()
{
iptunnel del ${TUNDEV}
# modprobe -r ipip
}
case "$1" in
start)
start ;;
stop)
stop ;;
restart)
stop
start ;;
esac
gad1:
/sbin/service tunnel_proxy2 start (运行隧道脚本)
隧道脚本:
#!/bin/bash
REMOTEIP=10.253.0.100
LOCALIP=10.253.0.101
#REMOTENET=192.168.80.0/24
TUNDEV=proxy2
TUNIP=192.168.237.25
NETMASK=255.255.255.252
start()
{
modprobe ipip
iptunnel add ${TUNDEV} mode ipip remote ${REMOTEIP} local ${LOCALIP}
ifconfig ${TUNDEV} ${TUNIP} netmask ${NETMASK}
# route add -net ${REMOTENET} gw ${GATEWAY} dev ${TUNDEV}
}
stop()
{
iptunnel del ${TUNDEV}
# modprobe -r ipip
}
case "$1" in
start)
start ;;
stop)
stop ;;
restart)
stop
start ;;
esac
问题:
Realserver上开启IIS服务,在client这台机器上访问 192.168.1.1这个地址,看到的却是192.168.1.1上的apach服务,为什么访问不到realserver:192.168.2.2的IIS服务?跪求解。
网通模式.jpg (50.25 KB, 下载次数: 6)
说明:
如图所示,所有的环境都是在虚拟机环境下做的,所有的网卡都是桥接模式。
proxy2和gad1是2台linux虚拟机,之间配置tunnel隧道。配置信息如下:
proxy2:
source /root/.bash_profile
/sbin/service tunnel_gad1 start (运行隧道配置)
/sbin/iptables -t nat -A PREROUTING -i eth0 -d 192.168.1.1 -p tcp --dport 80 -j DNAT --to 192.168.2.2:80
/sbin/route add -host 192.168.2.2 gw 192.168.237.25
/etc/init.d/httpd start
隧道脚本:
#!/bin/bash
REMOTEIP=10.253.0.101
LOCALIP=10.253.0.100
#REMOTENET=192.168.80.0/24
TUNDEV=gad1
TUNIP=192.168.237.26
NETMASK=255.255.255.252
start()
{
modprobe ipip
iptunnel add ${TUNDEV} mode ipip remote ${REMOTEIP} local ${LOCALIP}
ifconfig ${TUNDEV} ${TUNIP} netmask ${NETMASK}
# route add -net ${REMOTENET} gw ${GATEWAY} dev ${TUNDEV}
}
stop()
{
iptunnel del ${TUNDEV}
# modprobe -r ipip
}
case "$1" in
start)
start ;;
stop)
stop ;;
restart)
stop
start ;;
esac
gad1:
/sbin/service tunnel_proxy2 start (运行隧道脚本)
隧道脚本:
#!/bin/bash
REMOTEIP=10.253.0.100
LOCALIP=10.253.0.101
#REMOTENET=192.168.80.0/24
TUNDEV=proxy2
TUNIP=192.168.237.25
NETMASK=255.255.255.252
start()
{
modprobe ipip
iptunnel add ${TUNDEV} mode ipip remote ${REMOTEIP} local ${LOCALIP}
ifconfig ${TUNDEV} ${TUNIP} netmask ${NETMASK}
# route add -net ${REMOTENET} gw ${GATEWAY} dev ${TUNDEV}
}
stop()
{
iptunnel del ${TUNDEV}
# modprobe -r ipip
}
case "$1" in
start)
start ;;
stop)
stop ;;
restart)
stop
start ;;
esac
问题:
Realserver上开启IIS服务,在client这台机器上访问 192.168.1.1这个地址,看到的却是192.168.1.1上的apach服务,为什么访问不到realserver:192.168.2.2的IIS服务?跪求解。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论