How interesting.
I can’t remember anyone asking this question before(adding a massive number of aliases to a network interface).
And, I don’t see anything in any SUSE or openSUSE documentation.
Personally,
I’ve found that if you want to edit existing ifcfig files directly, all usual parameters are supported including adding alias addresses.
But using a script file?
A simple check reveals that the SUSE/openSUSE network script directory is in a different location.
I guess you can try placing the file you normally create in CentOS/RHEL/Fedora in this directory instead and see what happens
/etc/sysconfig/network/scripts/
Personally, if your desired address range is supported by a properly configured network address/network mask combination, I’d try adding that to the existing ifcfg file either by direct edit or by using the YaST > System > Network Settings > Select the Network Interface and Edit > Add…
I assume that the above attempt to define the range in a single entry is the most efficient way, but a quick Google search also turns up numerous less efficient ways to generate individual virtual interface files for each alias
For a pretty basic read on using the sysctl.conf file to persist core OS configurations across reboots, you can read an article I wrote a decade ago to modify TCP buffer settings and management starting on the following page, and for the 4 or so pages afterwards. Everything in that article should still apply to all openSUSE today.
If a configuration file named “ifcfg-eth0-range0” with content as described by peng_u is placed in ‘/etc/sysconfig/network/scripts/’ then “ifcfg” will, at boot-time, automatically setup IP addresses within the defined range.
I think what you described was mentioned first in my post…
Then followed by a number of other methods which I’d guess all should also work.
So,
there are likely many ways to do this…
The method you describe which is from the CentOS/RHEL/Fedora world assigns alias addresses in an address range similar to setting up a DHCP scope with a start and end address.
And, considering the similarities between Fedora and SUSE/openSUSE that might not be surprising.
But,
For those who might be more comfortable configuring a range using a netmask might consider the next method I suggested.
And,
For those who might want something that’s more generic across all distros, they might try the last methods I described with those pros/cons.
Looking at the openSUSE Leap 42.3 man page for “ifcfg” revealed the following:
EXAMPLES
Multiple addresses
You can extend the variable name IPADDR by any string you like. For example IPADDR_1, IPADDR-FOO or
IPADDRxxx. Use these variables for your IP addresses. If you need some additional parameters for
these addresses, then just add the same extension to these variable names: BROADCAST, NETMASK, PRE-
FIXLEN, REMOTE_IPADDR, LABEL, SCOPE, IP_OPTIONS.
Example:
IPADDR_AAA=1.2.3.4
NETMASK_AAA=255.0.0.0
BROADCAST_AAA=1.2.3.55
IPADDR_BBB=10.10.2.3/16
LABEL_BBB=BBB
and so on ...
And, “IPADDR_START”, “IPADDR_END”, and “CLONENUM_START” are not listed as being valid variables.
Yes, the synopsis for the openSUSE version of ‘ifcfg’ is: “/etc/sysconfig/network/ifcfg-*”.
On the other hand, the man page is dated “August 2004” and the copyright is “2004-2015 SUSE LINUX GmbH, Nuernberg, Germany.”
So, we will have to read some code to determine if the Red Hat (Fedora) variables are actually supported by the current openSUSE “ifcfg” implementation, or not.
[HR][/HR]Code is fact; Documentation is fiction . . .
Your post is useful, and I agree.
Without official documentation, it’s hard to state what will definitively work,
But, I hope my post was complete enough providing a number of tries of which more than likely several are almost guaranteed to work although because they are all a bit different personal preference should determine what should be tried first.
I have tried to put file ifcfg-eth0-range0 under /etc/sysconfig/scripts as CenOS does. But it doesn’t work. :’(
I’m using OpenSUSE 42.3
Now I do it manually,
ip addr add x.x.x.101 dev eth0 label eth0:1
ip addr add x.x.x.102 dev eth0 label eth0:2
ip addr add x.x.x.103 dev eth0 label eth0:3
ip addr add x.x.x.104 dev eth0 label eth0:4
ip addr add x.x.x.105 dev eth0 label eth0:5
ip addr add x.x.x.106 dev eth0 label eth0:6
ip addr add x.x.x.107 dev eth0 label eth0:7
ip addr add x.x.x.108 dev eth0 label eth0:8
…
as TSU said, I put these commands into /etc/sysctl.conf
to let it configured before nginx start.
Maybe in later version OpenSUSE, ip range function can be added.
Thks for posting your result.
If you’d like to perhaps see support for the CentOS script method,
I’d suggest you submit a “feature request” to https://bugzilla.opensuse.org.