Reducing 124 ifconfig lines in rc.conf to just 1

Polytropon freebsd at edvax.de
Sat Aug 2 19:44:38 UTC 2008


Hi!

On Sat, 2 Aug 2008 21:11:47 +0200, "Redd Vinylene" <reddvinylene at gmail.com> wrote:
> Greetings!
> 
> I got 124 ifconfig lines going from ifconfig_rl0_alias0="inet
> 80.252.2.3 netmask 255.255.255.255" to ifconfig_rl0_alias124="inet
> 80.252.2.127 netmask 255.255.255.255".
> 
> Is it possible reducing it all to just 1 line using a for loop or jot
> or something?

I'm thinking of a "two stage procedure" that can be implemented
well with /etc/rc.conf. Stupid idea, I know, but it should work,
allthough you could make it more tidy:

# First create /etc/ifconfig.conf if not already there
if [ ! -f /etc/ifconfig.conf ]; then
	echo "#!/bin/sh" > /etc/ifconfig.conf
	ALIAS=0
	while [ ${ALIAS} -lt 125 ]; do
		echo 'ifconfig_rl0_alias${ALIAS}="inet 80.252.2.`expr ${ALIAS} + 4` netmask 255.255.255.255" >> /etc/ifconfig.conf
		ALIAS=`expr ${ALIAS} + 1`
	done
fi

# Now source it into /etc/rc.conf
. /etc/ifconfig.conf

# Done.


-- 
Polytropon
>From Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list