With the current way aliases are handled it is not easy adding ip with different netmasks/broadcasts. Also it is setup differently for the primary ip number. I have made (not tested) a piece of code which would use the iface_eth0_0 variables in /etc/conf.d/net which are handled the same as the primary setting iface_eth0. Here is the code: if [ -n "$(eval echo \$\{iface_${IFACE}_0\})" ] then local num=0 ebegin " Adding aliases" while true do local iface_args="$(eval echo \$\{iface_${IFACE}_${num}\})" if [ -n "${iface_args}" ] then ebegin " ${IFACE}:${num}" /sbin/ifconfig ${IFACE}:${num} ${iface_args} >/dev/null num=$((num + 1)) eend 0 num=$((num + 1) else break fi done fi Hope this helps.
I see ipv6 numbers can be handled the same way Maybe iface_eth0 should be renamed inet4_eth0 or inet_eth0 for consistancy.
Without trying to be offensive, net.eth0 is already too complex for my taste. It should be a generic scipt that works for *most* people. If you need more, it is CONFIG_PROTECTed, and thus wont get overwritten. As for the inet4* stuff .. it will be considered, but changing it at this stage of the game could result in confusion, and breakage.
I agree with you about the complexity of the net.eth0 script When writing net.sit1 (ipv6 tunneling) I came to the conclusion that I was duplicating things from net.eth0. I don't think changing the way aliasing works would cause much of a problem, you could add my piece of code to the original one, as it uses different settings from /etc/conf.d/net. The put warning marks when it enters the original settings. And add comments to /etc/conf.d/net. I would like to take a shot at refactoring the net scripts, so that we can get a consistant and easy configuration for the different protocols, keep a temporary compatibility with the old configuration, and make the scripts simple.
To be honest, I thought about it again after posting last message. There is a better solution than the current. ---------------------------new alias code----------------------------------- if [ -n "$(eval echo \$\{alias_${IFACE}\})" ] then local x="" local num=0 local aliasbcast="" local aliasnmask="" ebegin " Adding aliases" for x in $(eval echo \$\{alias_${IFACE}\}) do aliasbcast="$(eval echo \$\{broadcast_${IFACE}\} \| awk \'\{ print \$${num} \}\')" if [ -n "${aliasbcast}" ] then aliasbcast="broadcast ${aliasbcast}" fi aliasnmask="$(eval echo \$\{netmask_${IFACE}\} \| awk \'\{ print \$${num} \}\')" if [ -n "${aliasnmask}" ] then aliasnmask="netmask ${aliasnmask}" fi ebegin " ${IFACE}:${num}" /sbin/ifconfig ${IFACE}:${num} ${x} \ ${aliasbcast} ${aliasnmask} >/dev/null num=$((num + 1)) eend 0 done save_options "alias" "$(eval echo \$\{alias_${IFACE}\})" fi ------------------------------------------------------------------------------ thus you alias config could look like follow: ------------------------------------------------------- alias_eth0="10.0.0.23 192.168.0.33" broadcast_eth0="10.0.0.255 192.168.0.255" netmask_eth0="255.0.0.0 255.255.255.0" ------------------------------------------------------- If broadcast_eth? or netmask_eth? is null, $aliasbcast $aliasnmask will be null as well, and it should work as without giving them as args. Comments welcome.
*** Bug 8030 has been marked as a duplicate of this bug. ***
The awk bits above: awk \'\{ print \$${num} \}\' should actually be: awk \'\{ print \$$((num+1)) \}\' Otherwise, it will not work for multiple aliases bound to the same interface ($0 == full record).
True, thanks.
The above bug ($num) is a show stopper ! It appeared on one of my production server and some daemons didn't start anymore (bind address didn't exist)... Please correct this ASAP !
It is on CVS. Ill do a new baselayout still this weekend. Edit it by hand for now, thanks.
*** Bug 9128 has been marked as a duplicate of this bug. ***
*** Bug 11893 has been marked as a duplicate of this bug. ***
... still having problems with this on baselayout 1.8.5.8
Explain ? Attach your net.eth0 please.
*** Bug 14636 has been marked as a duplicate of this bug. ***
I dont see a problem. Reopen if you actually want to explain your problem, and needed info.