非桌面版Debian 11自动配置获取ipv6地址教程
本文介绍了如何为Linux实例Debian 11系统自动配置IPv6地址和手动配置IPv6地址的方法。
自动配置IPV6
编辑interfaces文件
nano /etc/network/interfaces
在文本最后面添加:
iface xxx inet6 dhcp
上面的xxx看一下文本里小框框里面是啥(如下图),就更换成啥。我这里是enp0s3,所以我在最后面添加的就是iface enp0s3 inet6 dhcp,enp0s3是我服务器的网络接口。每个服务器的接口名字都有所不同。看着自己文本上面那个接口输入就行了。
最后ctrl+x保存,y确认。最后reboot重启。
开机后的系统就可以自动获取到ipv6地址了
查看ipv6地址:
ip -6 route show
ping测试ipv6是否通畅:
ping ipv6.google.com
可以ping通就说明一切就绪!
手动配置IPV6
root@debian11:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug ens18
auto ens18
iface ens18 inet dhcp
#增加以下行,然后重启网络/etc/init.d/networking restart即可
iface ens18 inet6 static
address 2a0d:2146:2404::1919
netmask 64
gateway 2a0d:2146:2404::1
修改系统dns,实现v4v6双栈dns解析
虽然只设置ipv4 dns也可以解析网络,但是我们ipv6地址都有了,设置一下ipv6 dns更加完美
nano /etc/resolv.conf
在最后添加一行,如下图
nameserver 2001:4860:4860::8888
最后ctrl+x保存,y确认。