2023/05/11

設定Ubuntu作業系統的IPv6隱私擴展

摘要

本文概要介紹幾個Ubuntu作業系統的IPv6隱私擴展(privacy extension)設定範例。

本文

這裡提到,IPv6位址包含8個區塊,每個區塊16位元、且使用4個位數十六進制數字來表示(一共128位元)。
  IPv6 addresses consist of 8 blocks of 16 bits each with four-digit hexadecimal numbers.

前面64位元為網路前綴。
  The first 64 bits are used for routing and designate the network prefix.

後面64位元為介面編號。
  The latter 64 bits are called Interface Identifiers (IID).

若介面編號基於EUI-64,將允許透由IPv6位址對底層MAC位址進行推斷,可能會引用使用者對於資料保護的擔憂;
若介面編號基於隱私擴展而臨時地(隨機地)產生,使得位址的主機部份得以匿名,則解開了這份擔憂。
  An IPv6 address based on the modified EUI 64 format allows inferences to be drawn about the underlying MAC address. Since this could raise data protection concerns among users, privacy extensions have been developed to make the host portion of IPv6 addresses anonymous. For this purpose, privacy extensions release the coupling of the interface identifier and MAC address and generates temporary interface identifiers for outbound connections.

預設之IPv6隱私擴展的啟用與否將因為Ubuntu作業系統版本的不同而出現差異;
例如Ubuntu 14.04預設停用IPv6隱私擴展,即啟用EUI-64格式,
再例如Ubuntu 20.04預設啟用IPv6隱私擴展,即停用EUI-64格式。

另外,若要持久地(permanently)啟用或停用IPv6隱私擴展,則要因應init程式進行調整;
這裡提到,以Ubuntu作業系統的init程式來說,Ubuntu 6.10之前為System V,Ubuntu 6.10以後為Upstart,Ubuntu 15.04以後為systemd
  Ubuntu started with System V Unix OS when it was launched and supported till the 6.10 release. After Ubuntu 6.10, in 2006, it featured the upstart system and changed to System D with Ubuntu 15.04.

設定範例如下所示。

切換IPv6隱私擴展範例;基於Ubuntu 20.04的systemd

參考這裡的描述。
Ubuntu 20.04預設啟用IPv6隱私擴展,所以link local位址fe80::896c:6a26:c584:f04、且IID的部份無法由EUI-48 MAC位址00:0c:29:14:4c:07推斷出來。

修改/etc/netplan/01-network-manager-all.yaml來配置Netplan,針對介面ens33。

以nmcli來設定Network Manager,將ipv6.addr-gen-mode設定為eui64。

修改/etc/sysctl.d/10-ipv6-privacy.conf來停用臨時IPv6位址。

重開機以完成切換;Ubuntu 20.04已停用IPv6隱私擴展,所以link local位址fe80::20c:29ff:fe14:4c07、且IID的部份可以由EUI-48 MAC位址00:0c:29:14:4c:07推斷出來。

切換IPv6隱私擴展範例;基於Ubuntu 14.04的Upstart

參考這裡的描述。
Ubuntu 14.04預設停用IPv6隱私擴展,所以link local位址fe80::20c:29ff:fe06:9e12、且IID的部份可以由EUI-48 MAC位址00:0c:29:06:9e:12推斷出來。

修改/etc/sysctl.conf來啟用臨時IPv6位址。

重開機以完成切換;Ubuntu 14.04已啟用IPv6隱私擴展,所以link local位址fe80::cb07:d7e0:c404:40cb、且IID的部份無法由EUI-48 MAC位址00:0c:29:06:9e:12推斷出來。

 

參考文獻

https://www.ionos.com/help/server-cloud-infrastructure/ip-addresses/ipv6-basics/
https://blog.packagecloud.io/ubuntu-a-journey-from-system-v-to-system-d/
https://gist.github.com/wanyvic/50405c94c06fe77f45331d9a11e41044
https://docs.bwipv6.de/docs/cheatsheets/linux/linux-kernel-parameter-sysctl/


沒有留言:

張貼留言