我正在尝试在运行Ubuntu 14.04 64位的AWS EC2 VPC实例上为Rust(游戏)设置专用服务器。 按照说明 ,我启动了应用程序并侦听其默认端口(UDP 28105,TCP 28106)。
netstat -tulpn
显示:
Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:28016 0.0.0.0:* LISTEN 7370/RustDedicated udp 0 0 0.0.0.0:28015 0.0.0.0:* 7370/RustDedicated udp 0 0 0.0.0.0:4209 0.0.0.0:* 7370/RustDedicated
这似乎看起来没问题,但试图连接到游戏客户端和远程控制台(RCON),拒绝了连接。 我怀疑这可能是一个典型的防火墙/安全组问题,所以为了testing目的,我将实例的安全组暴露给所有的端口。 还没有骰子。
相反,我决定查看是否至less可以在本地连接到应用程序正在运行的同一个盒子上的SSH会话。
我运行telnet 127.0.0.1 28106
其中产生:
Trying 127.0.0.1... telnet: Unable to connect to remote host: Connection refused
我的应用程序如何能够监听这个端口,但仍然拒绝来自它的环回地址的连接? 正如你所看到的,它被绑定到0.0.0.0
。
如何configuration这个,所以它不会抛出“连接被拒绝”?
编辑
sudo iptables -L
显示:
Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination
然后我使用应该允许连接的设置更新它:
Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT tcp -- anywhere anywhere tcp dpt:28016 flags:FIN,SYN,RST,ACK/SYN ACCEPT udp -- anywhere anywhere udp dpt:28015 ACCEPT tcp -- anywhere anywhere tcp dpt:28015 flags:FIN,SYN,RST,ACK/SYN Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination
在你的netstat你显示端口28016 TCP而不是28106和UDP 28015而不是28105。
同样在你的telnet中,你不是试图连接到打开的端口(28016 TCP),而是连接到你认为它打开的端口(28106 TCP)。