ubuntu 18.04.1 禁用ipv6

虚拟机重启以后,突然发现做好的docker端口映射不能使用了,docker本身还在运行,但是就是访问不了服务。

通过 netstat -lntp命令查看端口使用情况:

1
2
3
4
5
6
7
8
9
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp6 0 0 :::8069 :::* LISTEN -
tcp6 0 0 :::8071 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -

原来端口居然变成了tcp6

禁用ipv6

ubuntu 18.04.1 禁用ipv6的方法如下:

1
2
3
4
5
6
7
8
sudo vi /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1"
GRUB_CMDLINE_LINUX="ipv6.disable=1"
sudo update-grub
sudo reboot