大网数据广告活动
服务器运维问答

How do I configure netplan in Ubuntu 22.04 with dynamic IPv4 and static IPv6?

· 52CE 我爱测

With Ubuntu 22.04, the gateway option is deprecated and nearly every example I find for configuring netplan with static IPv6 uses gateway . My ISP's default /etc/netplan/01-netcfg.yaml only includes dynamic IPv4 and they do not p…

问题原文

原帖链接 · Paul · CC BY-SA 4.0

With Ubuntu 22.04, the gateway option is deprecated and nearly every example I find for configuring netplan with static IPv6 uses gateway.

My ISP's default /etc/netplan/01-netcfg.yaml only includes dynamic IPv4 and they do not provide DHCP support for IPv6, but they do provide support for static IPv6.

What do I add to the configuration to support IPv6?

$ cat /etc/netplan/01-netcfg.yaml
network:
  version: 2
  ethernets:
    eth0:
      dhcp4: true

I should also add that my ISP also does not provide nameserver support for IPv6 but they do provide an IPv6 address and a gateway IPv6 address.

Gateway IPv6 address:

2001:DB8:6404::1

Instance IPv6 address:

2001:DB8:6404:10fB:928a:b151:d721:51bc

已采纳解答

原帖链接 · Paul · CC BY-SA 4.0

I added to the configuration the dhcp6, addresses, nameservers, and routes to /etc/netplan/01-netcfg.yaml and it has been working so far:

network:
  version: 2
  ethernets:
    eth0:
      dhcp4: true
      dhcp6: no
      addresses:
        - 2001:DB8:6404:10fB:928a:b151:d721:51bc/48
      nameservers:
        addresses:
          - 2606:4700:4700::1111
          - 2606:4700:4700::1001
      routes:
        - on-link: true
          to: ::/0
          via: 2001:DB8:6404::1

The nameservers in the above configuration are for Cloudflare. Feel free to change them to something else.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2023-04-08)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。