
編輯:這可能是不可能的。根據網路計劃文檔,無法實現別名。如果不能,我想我需要想出另一個解決方案(例如使用舊的介面方法)。
編輯2:在不使用netplan try
和 只是 的情況下netplan apply
,我可以使用相同的綁定介面擁有多個IP 位址(請參閱下面的配置)。我現在回答我的問題。
我正在嘗試使用類似於此舊/etc/network/interfaces
設定的內容來實現 netplan 設定:
em1 Link encap:Ethernet HWaddr 12:34:56:78:90:12
inet addr:192.168.66.120 Bcast:192.168.127.255 Mask:255.255.192.0
inet6 addr: 1234:1234:1234:1234/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:121492924671 errors:0 dropped:4395640 overruns:0 frame:3517
TX packets:80073661297 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:112218751342378 (112.2 TB) TX bytes:26536012742300 (26.5 TB)
Interrupt:16
em1:1 Link encap:Ethernet HWaddr 12:34:56:78:90:12
inet addr:192.168.67.120 Bcast:192.168.127.255 Mask:255.255.192.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:16
em1:2 Link encap:Ethernet HWaddr 12:34:56:78:90:12
inet addr:192.168.67.121 Bcast:192.168.127.255 Mask:255.255.192.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:16
em1:3 Link encap:Ethernet HWaddr 12:34:56:78:90:12
inet addr:192.168.67.122 Bcast:192.168.127.255 Mask:255.255.192.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:16
em1:4 Link encap:Ethernet HWaddr 12:34:56:78:90:12
inet addr:192.168.67.123 Bcast:192.168.127.255 Mask:255.255.192.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:16
em1:5 Link encap:Ethernet HWaddr 12:34:56:78:90:12
inet addr:192.168.67.124 Bcast:192.168.127.255 Mask:255.255.192.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:16
但是,看來我的文法是錯的。我的伺服器上有 2 個網路卡,我正在嘗試在綁定上建立多個 IP 位址。但是,當我使用 時netplan try
,它告訴我:
bond0: reverting custom parameters for bridges and bonds is not supported
network:
bonds:
bond0:
addresses:
- 192.168.66.121/18
- 192.168.67.125/18
- 192.168.67.126/18
- 192.168.67.127/18
- 192.168.67.128/18
- 192.168.67.129/18
gateway4: 192.168.64.1
interfaces:
- eno1
- eno2
nameservers:
addresses:
- 192.168.3.222
- 192.168.70.80
parameters:
mode: active-backup
mii-monitor-interval: 100
ethernets:
eno1: {}
eno2: {}
version: 2
如果綁定了,其他 IP 位址應該放在哪裡?
答案1
此配置正在運行。我沒有使用別名。相反,我只是使用了單獨的 IP 位址,創建了一個測試防火牆策略,看起來一切都很好。
這是工作配置:
network:
bonds:
bond0:
addresses:
- 192.168.66.121/18
- 192.168.67.125/18
- 192.168.67.126/18
- 192.168.67.127/18
- 192.168.67.128/18
- 192.168.67.129/18
gateway4: 192.168.64.1
interfaces:
- eno1
- eno2
nameservers:
addresses:
- 192.168.3.222
- 192.168.70.80
parameters:
mode: active-backup
primary: eno1
mii-monitor-interval: 100
ethernets:
eno1: {}
eno2: {}
version: 2
renderer: networkd