如何使用 Netplan 在绑定接口上创建多个 IP 地址?

如何使用 Netplan 在绑定接口上创建多个 IP 地址?

编辑:这可能是不可能的。根据Netplan 文档,无法实现别名。如果不能,我想我需要想出另一个解决方案(例如使用旧的接口方法)。

编辑 2:不使用netplan try,而只使用netplan apply,我能够拥有具有相同绑定接口的多个 IP 地址(请参阅下面的配置)。我现在就回答我的问题。

我正在尝试使用与此旧设置类似的方法实现 netplan 设置/etc/network/interfaces

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

相关内容