I'd like to you to consider adding support for configuring multiple addresses on interface. E.g. Sometimes is needed to configure all /24 or more IP's on interface. As for now I'm using own very-dirty script started as service. E.g: config_ethX="1.2.3.4/24 2.2.2.25-143/24 5.5.0.1-5.5.1.254/23" Reproducible: Always
Patches welcome, but I think it would make more sense to just do the enumeration in a subshell instead. Something like: config_ethX="1.2.3.4/24 $(for ((x=25;x<=143;x++)); do echo 2.2.2.${x}/24 ; done) $(for ((x=1;x<=254;x++)); do echo 5.5.0.${x}/23 ; done) " ... note the above is just what comes to mind, there is probably shorter/prettier/better syntax one can use to enumerate a list like this.
I'd prefer not to have to write iteration code into netifrc, but I think Ian's subshell enumeration is better, but how about a compromise. I'll include a function to generate a range of CIDR addresses, and users should have that in a subshell call. Eg: config_ethX="$(netifrc_generate_range 5.5.0.0/23 5.5.0.1 5.5.1.254)" Args: block, first, last
This is bash, isn't it? config_ethX="1.2.3.4/24 2.2.2.{25..143}/24 5.5.{0..1}.{1..254}/23"
(In reply to Alex Xu from comment #3) > This is bash, isn't it? > > config_ethX="1.2.3.4/24 > 2.2.2.{25..143}/24 > 5.5.{0..1}.{1..254}/23" Or do you need a new line... *grumble* config_ethX="1.2.3.4/24 $(eval echo\ 2.2.2.{25..143}/24\;) $(eval echo\ 5.5.{0..1}.{1..254}/23\;)" Methinks maybe the for loop is better.
(In reply to Alex Xu from comment #4) > (In reply to Alex Xu from comment #3) > > This is bash, isn't it? > > > > config_ethX="1.2.3.4/24 > > 2.2.2.{25..143}/24 > > 5.5.{0..1}.{1..254}/23" > > Or do you need a new line... *grumble* > > config_ethX="1.2.3.4/24 > $(eval echo\ 2.2.2.{25..143}/24\;) > $(eval echo\ 5.5.{0..1}.{1..254}/23\;)" > > Methinks maybe the for loop is better. All of your examples here would leave out 5.5.0.255 and 5.5.1.0, which would be included in a proper iteration of the /23 netblock. This is why I proposed a helper function, to avoid missing bits like that.
(In reply to Robin Johnson from comment #5) > (In reply to Alex Xu from comment #4) > > (In reply to Alex Xu from comment #3) > > > This is bash, isn't it? > > > > > > config_ethX="1.2.3.4/24 > > > 2.2.2.{25..143}/24 > > > 5.5.{0..1}.{1..254}/23" > > > > Or do you need a new line... *grumble* > > > > config_ethX="1.2.3.4/24 > > $(eval echo\ 2.2.2.{25..143}/24\;) > > $(eval echo\ 5.5.{0..1}.{1..254}/23\;)" > > > > Methinks maybe the for loop is better. > > All of your examples here would leave out 5.5.0.255 and 5.5.1.0, which would > be included in a proper iteration of the /23 netblock. This is why I > proposed a helper function, to avoid missing bits like that. I'm probably wrong, but if we're assigning IPs, it is not valid to assign .255 or .0, being broadcast IPs.
(In reply to Alex Xu from comment #6) > I'm probably wrong, but if we're assigning IPs, it is not valid to assign > .255 or .0, being broadcast IPs. Your statement is almost correct: "It is not valid to assign broadcast IPs". Yes, it is not valid to assign broadcast OR network addresses as IPs to a host. The FIRST and LAST IPs of every range must not be assigned. However, in your 5.5.0.0/23 network, 5.5.0.255 and 5.5.1.0 aren't special at all, they are just regular IPs. In 5.5.0.0/23, your network address is 5.5.0.0, and the broadcast is 5.5.1.255. Similarly, at home, I used to have the public range 76.10.190.8/29. In this, 76.10.190.8 and 76.10.190.15 were not valid to assign to any system.
Oh, I see. It seems that it would be confusing to assign a /24 broadcast address though. What kind of use case is this for anyways? I'm sure there's a perfectly reasonable explanation whooshing over my head right now.
That is explicitly why I proposed a helper function, just so that users wouldn't have to worry about the complexity of network/broadcast addresses in CIDR blocks. It would just work for them to apply blocks of addresses.
Bug 91564 will also interest people. This was a baselayout-1 feature that has gotten lost somewhere along the way! It used to use bash expansion directly with arrays.
Status is "IN_PROGRESS" but is there any progress?;)