1、使用ifconfig命令查看网卡信息,如果出现了ipv6的信息证明ubuntu开启了ipv6

2、编辑配置文件/etc/sysctl.conf
vi /etc/sysctl.conf
加入内容
或者使用echo 的形式进行追加
net.ipv6.conf.all.disable_ipv6 = 1
echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf

3、echo "net.ipv6.conf.default.disable_ipv6 = 1" >>/etc/sysctl.conf

4、echo "net.ipv6.conf.lo.disable_ipv6 = 1" >>/etc/sysctl.conf

5、重启操作系统或者执行sysctl -p命令

6、操作完成之后继续使用ifconfig查看网卡信息
ifconfig
ipv6信息消失,ubuntu关闭ipv6成功
