點對點IP位址的網路遮罩?

點對點IP位址的網路遮罩?

在點對點隧道中,我能夠兩次擁有相同的 IP。它看起來像一個錯誤,我認為這可能與網路遮罩的某些內部表示有關。可以透過以下步驟重現它。

我創建了一個像這樣的tun隧道:

ip tuntap add dev tun3 mode tun user alice group alice
ip address add 10.8.0.1 peer 10.8.0.2/32 dev tun3

我列出了地址:

$ ip address list dev tun3
inet 10.8.0.1 peer 10.8.0.2/32 scope global tun3

如您所見,似乎沒有與 10.8.0.1 關聯的網路遮罩。但 ifconfig 報告 /32:

$ ifconfig tun3
inet 10.8.0.1  netmask 255.255.255.255  destination 10.8.0.2

如果我使用iproute2添加相同的地址10.8.0.1/32,則沒有錯誤,地址被添加然後列出。

# ip address add 10.8.0.1/32 dev tun3
$ ip address list dev tun3
inet 10.8.0.1 peer 10.8.0.2/32 scope global tun3
inet 10.8.0.1/32 scope global tun3

問題是,為什麼?我期待著:

    RTNETLINK answers: File exists

如果你想知道我為什麼要嘗試這個,我試著提供幫助這個問題

答案1

ifconfig您可以堅持使用ipiproute2 套件中的內容,而不是用於 IP 分配。它的手冊對此描述得很清楚:

man ip-address:「…

對等地址點對點介面的遠端端點的位址。再次,地址後面可以跟一個斜線和一個十進制數,編碼網路前綴長度如果指定對端位址,則本端位址不能有前綴長度網路前綴與對等方相關聯,而不是與本地位址相關聯

……”

相關內容