cs服务器的地址映射

王朝other·作者佚名  2008-05-18
窄屏简体版  字體: |||超大  

用iptables做防火墙;iptables的配置文件:

代码:

for this to run iptables firewall

#!/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 -o eth0 -j MASQUERADE

iptables -A FORWARD -s 0/0 -d 0/0 -j ACCEPT

iptables -t nat -A PREROUTING -d (外网 ip不要端口) -p udp --dport 27015(这个地址无所谓) -j DNAT --to (内网地址不要端口)

iptables -t nat -A POSTROUTING -d (内网地址) -p udp --dport 27015(端口就是内网cs服务器所用的端口启动脚本里面的那个+270xxx哪个) -o eth1 -j SNAT --to (内网网关)

iptables -t nat -A POSTROUTING -s (内网地址) -p udp --dport 27010:27012 -o eth1 -j SNAT --to (内网网关)

iptables -t nat -A POSTROUTING -s (内网地址) -p tcp --dport 5273 -o eth1 -j SNAT --to (内网网关)

iptables -t nat -A POSTROUTING -s (内网地址) -p tcp --dport 7002 -o eth1 -j SNAT --to (内网网关)

iptables -t nat -A POSTROUTING -s (内网地址) -p udp --dport 27010:27012 -o eth0 -j SNAT --to (外网地址)

iptables -t nat -A POSTROUTING -s (内网地址) -p tcp --dport 5273 -o eth0 -j SNAT --to (外网地址)

iptables -t nat -A POSTROUTING -s (内网地址) -p tcp --dport 7002 -o eth0 -j SNAT --to (外网地址)

-p 指定协议(--protocol)

--dport 指明端口(-- source-port/--sport和 --destination -port)

-i 或者-o 指定网络接口(PREROUTING链用-i POSTROUTING 用-o)

-s 指明源地址(--source/--src/源地址destination/--dst/目的地址)

-A 加入一个新规则到一个链(一般写到最后面)(append)

-I 在链内某个位置插入(insert)一般最后面

-R 在链内某个位置替换一条规则

-D 删除链内第一条规则(delete)

-d 指明目的地址

这样你的cs服务器就是外网ip:27015(其他的也可以)

_________________

代码:

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航