Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 482184 - net-misc/netifrc add support for assigning ranges of IP Addresses to an interface
Summary: net-misc/netifrc add support for assigning ranges of IP Addresses to an inter...
Status: IN_PROGRESS
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: netifrc (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: netifrc Team
URL:
Whiteboard: netifrc:iproute2 netifrc:ifconfig
Keywords:
Depends on: 91564
Blocks:
  Show dependency tree
 
Reported: 2013-08-23 08:40 UTC by Marcin Mirosław
Modified: 2021-02-02 06:04 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marcin Mirosław 2013-08-23 08:40:18 UTC
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
Comment 1 Ian Stakenvicius (RETIRED) gentoo-dev 2013-08-23 16:07:22 UTC
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.
Comment 2 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2013-08-23 16:19:08 UTC
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
Comment 3 Alex Xu (Hello71) 2013-08-23 22:32:21 UTC
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"
Comment 4 Alex Xu (Hello71) 2013-08-23 22:38:11 UTC
(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.
Comment 5 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2013-08-23 23:13:27 UTC
(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.
Comment 6 Alex Xu (Hello71) 2013-08-23 23:31:26 UTC
(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.
Comment 7 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2013-08-23 23:42:27 UTC
(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.
Comment 8 Alex Xu (Hello71) 2013-08-23 23:52:38 UTC
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.
Comment 9 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2013-08-23 23:59:52 UTC
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.
Comment 10 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2013-08-24 00:12:24 UTC
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.
Comment 11 Marcin Mirosław 2016-04-16 23:52:47 UTC
Status is "IN_PROGRESS" but is there any progress?;)