shinyrose 发表于 2006-7-20 12:28:27

求助:CS服务器端口映射问题。

Linux+squid+nat透明代理路

内网的服务器映射出去.可是在外网以及内网用HLSW连接后的结果,是一断一断的。连接的时候也是隔上5秒-10秒 就连接不上去了.外网连接进来全部显示代理服务器的IP,管理极不方便.
我用的是iptables
网关:192.168.0.1/255.255.255.0
外网:eth0,内网:eth1
CS服务器是192.168.0.254 ,iptables的语法是这样的
*********
#!/bin/sh
/sbin/modprobe ip_tables
/sbin/modprobe ip_nat_ftp
/sbin/modprobe ip_conntrack_ftp
/sbin/iptables -F
/sbin/iptables -F -t nat
/sbin/iptables -X
/sbin/iptables -Z

echo"1">/proc/sys/net/ipv4/ip_forward
/sbin/iptables -P INPUT ACCEPT
/sbin/iptables -P FORWARD ACCEPT
/sbin/iptables -P OUTPUT ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j SNAT --to xxx.xxx.xxx.xxx
iptables -A FORWARD -s 0/0 -d 0/0 -j ACCEPT
iptables -A PREROUTING -s 192.168.0.0/24 -i eth1 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
iptables -A PREROUTING -s 192.168.0.0/24 -i eth1 -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 3128

iptables -A INPUT -p icmp --icmp-type 8 -s 0/0 -j DROP
iptables -A INPUT -p icmp --icmp-type 0 -s 0/0 -j ACCEPT

/sbin/iptables -t nat -A PREROUTING -d xxx.xxx.xxx.xxx -p udp --dport 27015 -j DNAT --to 192.168.0.254
/sbin/iptables -t nat -A POSTROUTING -d 192.168.0.254 -p udp --dport 27015 -o eth1 -j SNAT --to 192.168.0.1
/sbin/iptables -t nat -A POSTROUTING -s 192.168.0.254 -p udp --dport 27010:27012 -o eth1 -j SNAT --to 192.168.0.1
/sbin/iptables -t nat -A POSTROUTING -s 192.168.0.254 -p tcp --dport 5273 -o eth1 -j SNAT --to 192.168.0.1
/sbin/iptables -t nat -A POSTROUTING -s 192.168.0.254 -p tcp --dport 7002 -o eth1 -j SNAT --to 192.168.0.1
/sbin/iptables -t nat -A POSTROUTING -s 192.168.0.254 -p udp --dport 27010:27012 -o eth0 -j SNAT --to 202.103.xxx.xxx
/sbin/iptables -t nat -A POSTROUTING -s 192.168.0.254 -p tcp --dport 5273 -o eth0 -j SNAT --to XXX.XXX.xxx.xxx
/sbin/iptables -t nat -A POSTROUTING -s 192.168.0.254 -p tcp --dport 7002 -o eth0 -j SNAT --to xxx.xxx.xxx.xxx


**********
大家给我看看出什么问题了~~~
很有周期性的
外网进去玩不会出现断线的现象,完全是正常玩的。

shinyrose 发表于 2006-7-20 12:31:16

在网上找了一篇跟我问题一样的问题的解决方法.是RouterOS的解决方法.
能不能帮我照他们的意思解决一下LIUNX+SQUID+NAT的问题?


原帖:http://www.dcoo.com/bbs/dispbbs.asp?boardID=86&ID=58721&page=14

解决网吧CSSV难刷和外网玩家进入SV后显示内网网关问题此帖只针对RouterOS软路由。不是用RouterOS希望能给遇到这个问题的朋友一个启示。自己慢慢摸索.

比如我的CS服务器,外网玩家进入服务器后都变成网关192.168.0.1,如果有人作弊封IP的话就会把外网的玩家全封掉,在外网用OP命令要输好几次服务器才响应,用HLSW经常会连接中断,外网要刷好几次才能刷出服务器。只要在路由里做简单的设置,上面的毛病统统没有了。
打开Mikrotik管理界面IP ----------- Firewall ------------ NAT----选中masquerade(伪装)在src。address里面添入:内网IP段/24,,比如192.168.0.0/24
其他不用设置。

[ 本帖最后由 shinyrose 于 2006-7-20 12:32 编辑 ]

shinyrose 发表于 2006-7-20 12:33:55

帮帮忙,不胜感激!!!

hb2k 发表于 2006-7-20 16:32:17

#!/bin/sh
/sbin/modprobe ip_tables
/sbin/modprobe ip_nat_ftp
/sbin/modprobe ip_conntrack_ftp
/sbin/iptables -F
/sbin/iptables -F -t nat
/sbin/iptables -X
/sbin/iptables -Z

echo"1">/proc/sys/net/ipv4/ip_forward
/sbin/iptables -P INPUT ACCEPT
/sbin/iptables -P FORWARD ACCEPT
/sbin/iptables -P OUTPUT ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j SNAT --to xxx.xxx.xxx.xxx
iptables -A PREROUTING -s 192.168.0.0/24 -i eth1 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
iptables -A PREROUTING -s 192.168.0.0/24 -i eth1 -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 3128

iptables -A INPUT -p icmp --icmp-type 8 -s 0/0 -j DROP
iptables -A INPUT -p icmp --icmp-type 0 -s 0/0 -j ACCEPT

/sbin/iptables -t nat -A PREROUTING -d xxx.xxx.xxx.xxx -p udp --dport 27015 -j DNAT --to 192.168.0.254:27015
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -d 192.168.0.0/24 -j SNAT --to 192.168.0.1(回流)
不用管协议了。把剩下的管理端口一一映射即可。

hb2k 发表于 2006-7-20 17:04:20

回复 #3 shinyrose 的帖子

还有可能是你内网的问题。比如网络故障或arp欺骗。

shinyrose 发表于 2006-7-20 20:39:04

根据您的提示,问题已经解决,谢谢软件路由论坛的版主.
iptables -t nat -A PREROUTING -d xxx.xxx.xxx.xxx -p udp --dport 27016 -j DNAT --to-destination 192.168.0.254:27016
iptables -A FORWARD -p udp -d 192.168.0.254 --dport 27016 -j ACCEPT
iptables -t nat -I POSTROUTING -s 192.168.0.0/255.255.255.0 -p udp -d 192.168.0.254 --dport 27016 -j SNAT --to 192.168.0.1
就这样的语句.

hb2k 发表于 2006-7-22 17:17:31

回复 #6 shinyrose 的帖子

还是有较大区别的。
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -d 192.168.0.0/24 -j SNAT --to 192.168.0.1
源地址为192.168.0.0/24的主机所发的数据报,如果目的地址也是192.168.0.0/24的话那么伪装成192.168.0.1
结合iptables -t nat -A PREROUTING -d xxx.xxx.xxx.xxx -p udp --dport 27015 -j DNAT --to 192.168.0.254:27015
实现所谓的“回流”。
iptables -t nat -I POSTROUTING -s 192.168.0.0/255.255.255.0 -p udp -d 192.168.0.254 --dport 27016 -j SNAT --to 192.168.0.1
源地址为192.168.0.0/24(可以按照你那么写么?) 而且是udp数据报,目的地址是192.168.0.254而且目的端口是27016的话,那么伪装成192.168.0.1。只对指定协议指定端口做回流处理,算作不完全回流。

无焰之火 发表于 2007-4-8 01:21:20

试过依然是老问题,依然断流,外网进入依然是网关的IP

36587285 发表于 2007-5-14 19:01:29

我的2.927显示的还是网关IP
页: [1]
查看完整版本: 求助:CS服务器端口映射问题。