We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
内核版本:4.4.0-142-generic,os:Ubuntu14.04 端口映射到宿主机,使用 telnet访问宿主机分配给容器的端口,连接失败
# telnet 172.31.93.218 90 Trying 172.31.93.218... telnet: Unable to connect to remote host: Connection refused
The text was updated successfully, but these errors were encountered:
开始我以为是我代码的问题,后面使用了6.5版本的代码,发现也无法实现端口转发,Ubuntu开启了 ip_forward 功能
ip_forward
Sorry, something went wrong.
bro找到解决方法了吗,这边也是同样的情况
找到原因了。假如当前映射是【宿主机80端口:容器80端口】,那么根据代码,端口映射时会用iptables来配置【PREROUTING】链上的DNAT,但PREROUTING规则是用来处理【外部进入】的连接的(同一局域网上的其它机器),在宿主机上自己进行发起连接时,并不会走这条链的规则,而是去走【OUTPUT】这条链的规则。 通过检查PREROUTING规则上的【pkts】和【bytes】属性,也能够发现在进行telnet时,数据包不会经过这条链。但如果用另一台处于同一局域网段的机器发起telnet就能够成功DNAT并连接。
把这个DNAT规则在PREROUTING和OUTPUT两条链都加上即可。
No branches or pull requests
内核版本:4.4.0-142-generic,os:Ubuntu14.04
端口映射到宿主机,使用 telnet访问宿主机分配给容器的端口,连接失败
# telnet 172.31.93.218 90 Trying 172.31.93.218... telnet: Unable to connect to remote host: Connection refused
The text was updated successfully, but these errors were encountered: