我有两台机器(Machine1和Machine2)在同一个子网上。 Machine1安装了一个工具来返回一些数据。 例如,如果我运行以下命令,它会返回一些数据。
printf "get:info\nend\n" | nc localhost 1234
但是,如果在Machine2上执行相同的操作,当然将localhost更改为machine1,则什么都不会发生。 任何想法可能是什么问题?
printf "get:info\nend\n" | nc machine1 1234
在调查了很多之后,我终于找到了无法与特定端口上的其他机器通信的原因。
我的machine1中的iptables设置不允许machine1侦听。 我关掉了iptables,并且运行正常。
但是关掉iptables不是个好主意。 所以下一步,我允许machine1的端口1234。
sudo iptables -A INPUT -p tcp --dport 1234 -j ACCEPT
您可以在下面的链接中找到更多关于iptables的信息:
https://help.ubuntu.com/community/IptablesHowTo