18.04 - 如何禁用临时/隐私 IPv6 地址?

J D*_*Doe 6 ipv6 networking netplan 18.04

我安装了 18.04,我将它用作跳箱来接触其他东西。

我需要访问的某些内容只能通过 IPv6 访问,并希望我从特定的 IPv6 地址进行连接,因此我的机器配置了静态 IPv6 地址。

出于某种原因,我似乎无法阻止 Ubuntu 生成和首选隐私 IPv6 地址。这意味着当我尝试连接到其他东西时,我似乎来自错误的 IPv6 地址。

我已经使用静态 IPv6 地址配置了 Netplan(显示的示例地址 - 我并没有真正使用它)

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    ens192:
      dhcp4: no
      dhcp6: no
      addresses: [192.168.212.152/25, '2001:0db8:85a3:0000::98/128']
      gateway4: 192.168.212.129
      nameservers:
        search: ['mydomain.local']
        addresses: [192.168.212.141, 192.168.212.142, '2001:0db8:85a3:0000::8d', '2001:0db8:85a3:0000::8e']
Run Code Online (Sandbox Code Playgroud)

我在 /etc/sysctl.d/10-ipv6-privacy.conf 中将 sysctl 配置为不使用 IPv6 隐私寻址:

# IPv6 Privacy Extensions (RFC 4941)
# ---
# IPv6 typically uses a device's MAC address when choosing an IPv6 address
# to use in autoconfiguration. Privacy extensions allow using a randomly
# generated IPv6 address, which increases privacy.
#
# Acceptable values:
#    0 - don’t use privacy extensions.
#    1 - generate privacy addresses
#    2 - prefer privacy addresses and use them over the normal addresses.
net.ipv6.conf.all.use_tempaddr = 0
net.ipv6.conf.default.use_tempaddr = 0



$ sysctl net.ipv6.conf.ens192.use_tempaddr
net.ipv6.conf.ens192.use_tempaddr = 0
Run Code Online (Sandbox Code Playgroud)

我仍然得到一个临时的 IPv6 地址:

$ ip -6 addr
2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000
    inet6 2001:0db8:85a3:0000:20c:29ff:fede:fa42/64 scope global dynamic mngtmpaddr noprefixroute
       valid_lft 2591895sec preferred_lft 604695sec
    inet6 2001:0db8:85a3:0000::98/128 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fede:fa42/64 scope link
       valid_lft forever preferred_lft forever
Run Code Online (Sandbox Code Playgroud)

我可以删除隐私地址或将其设置为已弃用,但只要我申请或重新启动网络计划,它就会重新出现。

我做错了什么还是这是一个错误?

Tho*_*ger 1

我有同样的问题。我首先尝试在sysctl.conf中禁用ipv6 autoconf和accept_ra

# sysctl -p
net.ipv6.conf.all.autoconf = 0
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.lan.autoconf = 0
net.ipv6.conf.lan.accept_ra = 0
net.ipv6.conf.wan.autoconf = 0
net.ipv6.conf.wan.accept_ra = 0
Run Code Online (Sandbox Code Playgroud)

但这并没有改变任何事情。由于netplan有一些计时问题,我在netplan yaml文件中禁用了accept_ra。

/etc/netplan/50-cloud-init.yaml

addresses:
- xxx.xxx.xxx.xxx/24
- xxxx:xxxx:xxxx::xx/64
dhcp4: false
dhcp6: false
accept-ra: false
Run Code Online (Sandbox Code Playgroud)


Ott*_*sen 0

将“accept-ra: false”放在 .yaml 文件中的接口配置下。