运维开发网
广告位招商联系QQ:123077622
 
广告位招商联系QQ:123077622

CentOS7 docker容器映射出的端口只监听在ipv6上的解决办法

运维开发网 https://www.qedev.com 2021-05-09 12:19 出处:51CTO 作者:兰朝亚
CentOS7 docker容器映射出的端口只监听在ipv6上的解决办法,Record Mark原创的Linux文章。

Docker容器起来以后,查看端口监听情况,如下图:

[[email protected]]# ss -tnl
State       Recv-Q Send-Q                     Local Address:Port                                    Peer Address:Port              
LISTEN      0      100                            127.0.0.1:25                                                 *:*                  
LISTEN      0      128                                    *:3330                                               *:*                  
LISTEN      0      5                                      *:8911                                               *:*                  
LISTEN      0      100                                [::1]:25                                              [::]:*                  
LISTEN      0      128                                 [::]:3330                                            [::]:*                  
LISTEN      0      128                                 [::]:10051                                           [::]:*                  
LISTEN      0      128                                 [::]:33060                                           [::]:*                  
LISTEN      0      5                                   [::]:8911                                            [::]:*                  
LISTEN      0      128                                 [::]:80                                              [::]:*

端口10051,80,33060只监听在ipv6上,使用ipv4无法访问。

解决办法如下:

编辑/etc/default/grub,加入一行:

GRUB_CMDLINE_Linux="ipv6.disable=1 ..."

保存后重新配置grub并重启服务器

# grub2-mkconfig -o /boot/grub2/grub.cfg

# reboot

重启后结果:

[[email protected]~]# ss -tnl
State       Recv-Q Send-Q                     Local Address:Port                                    Peer Address:Port              
LISTEN      0      128                                    *:3330                                               *:*                  
LISTEN      0      128                                    *:10051                                              *:*                  
LISTEN      0      128                                    *:33060                                              *:*                  
LISTEN      0      5                                      *:8911                                               *:*                  
LISTEN      0      128                                    *:80                                                 *:*                  
LISTEN      0      100                            127.0.0.1:25                                                 *:*

正常了。

扫码领视频副本.gif

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号