歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux資訊 >> 更多Linux >> cs服務器的地址映射

cs服務器的地址映射

日期:2017/2/27 14:21:17   编辑:更多Linux
  用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(其他的也可以) _________________ 代碼:




Copyright © Linux教程網 All Rights Reserved