使用 Netplan 的 IP 范围

亚历克斯·里奥

是否可以使用静态 IP 范围配置 Netplan?或者您是否需要像旧的 ifupdown 配置一样指定每个 IP。

基本上我想做一些类似于 RedHat 的事情:

IPADDR_START=192.168.0.2
IPADDR_END=192.168.0.254
PREFIX=24
CLONENUM_START=0

旧方法是这样做的:https : //serverfault.com/questions/27160/how-to-add-multiple-24-network-ips-in-ubuntu

iface eth0 inet static
  address 192.168.0.1
  netmask 255.255.255.0
  up ip addr add 192.168.0.2/24 dev eth0
  up ip addr add 192.168.0.3/24 dev eth0
  up ip addr add 192.168.0.4/24 dev eth0
  up ip addr add 192.168.0.5/24 dev eth0
  ...

我是否需要像波纹管一样指定每个 IP 或者是否有更简单的方法来指定范围?

# This file is generated from information provided by 
# the datasource. Changes to it will not persist across an instance. 
# To disable cloud-init's network configuration capabilities, write a file 
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: 
# network: {config: disabled} 

network: 
    renderer: networkd 
    ethernets:  
        enp0s3: 
            addresses: [192.168.0.2/24, 192.168.0.3/24, ... , 192.168.0.254/24 ]  
            gateway4: 192.168.0.1  
            nameservers:  
                addresses: [8.8.8.8,8.8.4.4]  
            dhcp4: no 
    version: 2 
斯兰加塞克

不,这无法通过 netplan 实现。可以想象,您可以从在其他地方运行的脚本生成您的 netplan yaml,将您的范围扩展到 netplan 所需的地址列表中,而不必手动维护此列表。但是 netplan 本身并没有为接口分配 IP 地址范围的概念(我也不认为我们可能会添加这样的功能,因为我不相信这是一种常见的配置)。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章