我正在尝试打开一些端口游戏服务器,它在我的 Linux vServer(Ubuntu 14.04 LTS 64 位)上运行。游戏需要以下端口:
16261 (UDP)
16262 (TCP) // Player 1
16263 (TCP) // Player 2
16264 (TCP) // Player 3
16265 (TCP) // Player 4
// ...
由于我对 Linux 不是很熟悉,所以我搜索了一些在 Ubuntu 上打开端口的方法。我遵循了此处描述的步骤并输入:
iptables -A INPUT -p udp --dport 16261 -j ACCEPT
iptables -A INPUT -p tcp --dport 16262 -j ACCEPT
为了确保它有效,我检查了 iptablesiptables -L
并得到了如下列表:
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
REJECT tcp -- anywhere anywhere tcp flags:!FIN,SYN,RST,ACK/SYN state NEW reject-with tcp-reset
DROP all -- anywhere anywhere state INVALID
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere tcp dpt:8443
ACCEPT tcp -- anywhere anywhere tcp dpt:8880
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:smtp
ACCEPT tcp -- anywhere anywhere tcp dpt:urd
ACCEPT tcp -- anywhere anywhere tcp dpt:pop3
ACCEPT tcp -- anywhere anywhere tcp dpt:pop3s
ACCEPT tcp -- anywhere anywhere tcp dpt:imap2
ACCEPT tcp -- anywhere anywhere tcp dpt:imaps
ACCEPT tcp -- anywhere anywhere tcp dpt:poppassd
DROP tcp -- anywhere anywhere tcp dpt:mysql
ACCEPT tcp -- anywhere anywhere tcp dpt:postgresql
ACCEPT tcp -- anywhere anywhere tcp dpt:9008
ACCEPT tcp -- anywhere anywhere tcp dpt:9080
ACCEPT udp -- anywhere anywhere udp dpt:netbios-ns
ACCEPT udp -- anywhere anywhere udp dpt:netbios-dgm
ACCEPT tcp -- anywhere anywhere tcp dpt:netbios-ssn
ACCEPT tcp -- anywhere anywhere tcp dpt:microsoft-ds
ACCEPT udp -- anywhere anywhere udp dpt:openvpn
DROP udp -- anywhere anywhere udp dpt:domain
DROP tcp -- anywhere anywhere tcp dpt:domain
ACCEPT icmp -- anywhere anywhere icmptype 8 code 0
ACCEPT all -- anywhere anywhere
ACCEPT udp -- anywhere anywhere udp dpt:16261
ACCEPT tcp -- anywhere anywhere tcp dpt:16262
这两个新条目实际上在列表中,但是当我已检查查看两个端口是否打开,结果显示两个端口 (16261/26262) 仍处于关闭状态。我做错了什么?Teamspeak 3 和 CS:GO 服务器已经正常运行……
编辑:我在其他地方读到过,我也可以使用 检查开放端口netstat -ntulp
。如果我输入此命令,则两个端口不会显示在列表中。