SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
############################
# DETERMINE INTERFACE LIST #
############################
# Compose a list of interfaces from /etc/rc.d/rc.inet1.conf (with a maximum
# of 6 interfaces, but you can easily enlarge the interface limit
# - send me a picture of such a box :-).
# If a value for IFNAME[n] is not set, we assume it is an eth'n' interface.
# This way, the new script is compatible with older rc.inet1.conf files.
# The IFNAME array will be used to determine which interfaces to bring up/down.
MAXNICS=${MAXNICS:-6}
i=0
while [ $i -lt $MAXNICS ];
do
IFNAME[$i]=${IFNAME[$i]:=eth${i}}
i=$(($i+1))
done
if [ "$DEBUG_ETH_UP" = "yes" ]; then
echo "/etc/rc.d/rc.inet1: List of interfaces: '${IFNAME[@]}'" | $LOGGER
fi
I have a situation that need more than 6 (Maybe 7).
I set an ip address and it can't be valid until I ifconfig that.
Finally, I found this code in rc.inet1.
I want to know why the number is 6? Is it about the performance or any other reason?
Thx.
Pre-vacuum-tube computers take a lot of time to loop through large number of empty setups. This is the evidence of slackware being the oldest surviving Linux distribution.
Pre-vacuum-tube computers take a lot of time to loop through large number of empty setups. This is the evidence of slackware being the oldest surviving Linux distribution.
... which is reason to avoid having a arbitrary limit.
A long while ago I wrote myself an rc.inet1 replacement modeled on the OpenBSD approach.
It cycles through the interfaces listed on it's args, or if none, the interfaces it finds in /proc/net/dev and if it finds a corresponding /etc/hostname.<interface> file uses that to configure the interface. I find this much easier to work with than the stock rc.inet1 + rc.inet1.conf approach, which has always seemed a little unwieldy to me.
As you can see, it also allows static routes to be kept with the associated interface config, which keeps things nice and tidy. To use dhclient, the file simply needs contain the word 'dhcp'. I've not fleshed it out to support wifi yet, but a "!wpa_supplicant blah blah...." line before a "dhcp" line ought to do the job.
... which is reason to avoid having a arbitrary limit.
It cycles through the interfaces listed on it's args, or if none, the interfaces it finds in /proc/net/dev and if it finds a corresponding /etc/hostname.<interface> file uses that to configure the interface. I find this much easier to work with than the stock rc.inet1 + rc.inet1.conf approach, which has always seemed a little unwieldy to me.
As you can see, it also allows static routes to be kept with the associated interface config, which keeps things nice and tidy. To use dhclient, the file simply needs contain the word 'dhcp'. I've not fleshed it out to support wifi yet, but a "!wpa_supplicant blah blah...." line before a "dhcp" line ought to do the job.
Normally, I think it is simple if I configure all interfaces in one file. If move the interfaces to multiple files, I need to configure them in multiple place.
I think rc.inet1.conf can be scanned to summate amout of the interfaces, but it seems ugly and not KISS.
I can remember we've talked about this sort of thing in the past, so I suspect you may have already seen it, but I'll attach it here anyway. It's not particularly sophisticated, but that's why I like it
BTW, if anyone tries it out, don't forget to create a /etc/hostname.lo containing "inet 127.0.0.1"
If the problem originates from having extra IP's and not actual interfaces then I think I can help.
I have below rc.inet1 and rc.inet1.conf that I use, the IP addresses used are in CIDR notation and the setup no longer uses net masks (ignore the ones in the conf they are not used.)
To add extra IP's on an interface you simply separate them with spaces so you could have the following :-
Pre-vacuum-tube computers take a lot of time to loop through large number of empty setups. This is the evidence of slackware being the oldest surviving Linux distribution.
if i remember correctly, about a years 2003 - 2005 i have linux slackware ( 10.0 or so on version) based firewall \ router with 7 NIC. i do not change anything in rc.inetd1 - maybe then there are not that string?
Ideal solution would be for rc.inet1 to deal with any # of interfaces, without having to hardcode a specific #.
Failing that, would suggest Slackware to default to 10 interfaces, instead of 6 - that would cover many more servers by default, without "new players" (and old players) falling into this very difficult-to-debug trap. Really got lucky here that I was able to drag out this knowledge from my head that I forgot so long ago.
(note the array indices numbers)
which is perfectly legal syntax in both bash and the rc.inet1.conf file.
In order to make sure both the interfaces get assigned, you need to know the highest indices in order to know when to stop processing. You can't just look for an empty definition for IPADDRS and stop there as there are 'holes' in the array where that indices is not defined. You also cannot loop forever just in case someone defined a stupidly high number. And every iteration of the loop costs real time, which undoubtedly slows down rc.inet1 to a point where people would complain that their system takes longer to boot.
So, we need somewhere to stop the loop. Historically this was after 6 iterations. When I re-wrote rc.inet1 for 15.0, I kept that "tradition", as is the Slackware way. I also kept in Pat's original comment regarding sending him a picture for the same reason
I agree that a lot of systems these days are going to have more than 6 interfaces (or more than 6 interface definitions, as virtual interfaces and bonds also count in rc.inet1.conf) and MAXNICS could realistically be set higher these days - Pat may even accept a patch to raise it if you submit one.
I kept the tradition of 6. It's really as simple as that. But, setting it too high is going to slow down processing of rc.inet1 during boot. Also, where do you set the value? Everyone and their dog is going to have an opinion on what the value should be - and have arguments as to why it should be that high because their server has X interfaces, when yours only has X-1.
So, that's it really. That's the rationale as to why I kept it at 6 - but try your luck with a patch to Pat...
Sorry for the long post, but I thought it worthwhile to put this issue to bed once and for all
bash does not have an expansion for providing the highest indices of an array
You can use the ${!IFNAME[@]} construction to get a list of the indices and assign that to an array.
My suggestion for this.
Code:
# diff -u3 a/rc.inet1 b/rc.inet1
--- a/rc.inet1 2022-03-28 01:10:55.693900246 +1100
+++ b/rc.inet1 2022-03-28 01:31:22.430882036 +1100
@@ -49,11 +49,13 @@
# If a value for IFNAME[n] is not set, we assume it is an eth'n' interface.
# This way, the new script is compatible with older rc.inet1.conf files.
# The IFNAME array will be used to determine which interfaces to bring up/down.
-MAXNICS=${MAXNICS:-6}
+MAXNICS=${#IFNAME[@]}
+NICINDEX=( ${!IFNAME[@]} )
i=0
while [ $i -lt $MAXNICS ];
do
- IFNAME[$i]=${IFNAME[$i]:=eth${i}}
+ j=${NICINDEX[$i]}
+ IFNAME[$j]=${IFNAME[$j]:=eth${j}}
i=$((i+1))
done
debug_log "List of interfaces: ${IFNAME[*]}"
@@ -245,7 +247,7 @@
# Determine position 'i' of this interface in the IFNAME array:
i=0
while [ $i -lt $MAXNICS ]; do
- [ "${IFNAME[$i]}" = "${1}" ] && break
+ [ "${IFNAME[${NICINDEX[$i]}]}" = "${1}" ] && break
i=$((i+1))
done
# If "i" is greater or equal to "MAXNICS" at this point, it means we didn't
@@ -539,7 +541,7 @@
# Determine position 'i' of this interface in the IFNAME array:
i=0
while [ $i -lt $MAXNICS ]; do
- [ "${IFNAME[$i]}" = "${1}" ] && break
+ [ "${IFNAME[${NICINDEX[$i]}]}" = "${1}" ] && break
i=$((i+1))
done
if [ $i -ge $MAXNICS ]; then
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.