0

Is it possible to configure Netplan with Static IP range? Or do you need to specify each IP like in old ifupdown configuration.

Basically I want to do something similar to RedHat:

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

The old way is doing this way: 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
  ...

Would I need to just specify each IP like bellow or is there a simpler way to specify a range?

# 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 
0

No, this is not possible through netplan. You could conceivably generate your netplan yaml from a script that you run elsewhere, to expand your range into the list of addresses required by netplan instead of having to maintain this list manually. But netplan does not itself have the concept of assigning a range of IP addresses to an interface (nor do I think we would likely add such a feature, as I don't believe this is a common configuration).

  • Gotcha, thanks for the explanation – Alex Leo Apr 24 at 2:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.