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

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

[root@backup01 gcc-8.1.0]# 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

重启后结果:

[root@backup01 ~]# 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                                                 *:*

正常了。

上一篇:CentOS7在VMware下设置成桥接模式


下一篇:免费都不管用,Win10升级在中国怎么就这么难?