Hi folks, Apologies for the delay in sending this out
Thanks for replies from
karrer@bernina.ethz.ch
mills@ccu.umanitoba.ca
Dave @ UK Sun Support <- the best response although not an official fix
To summarise, Sun's 4.1.x "ifconfig" program does not support the address
schemes based on all-1's broadcast.
"Under Solaris 2.x, all 1's broadcast is the standard, so ifconfig will
conform to this."
However if you want to fix this now you either must:
- write a C program to issue system calls on the interface.
- write a C or shell program to calculate the broadcast address to stuff into an
ifconfig command
I haven't yet asked for permission to post the first C programs, but
I have for the script, which has the added advantage that it only
requires a change to the /etc/rc.local and nothing else.
Issue:
Should we really be fixing the broadcast address in /etc/rc.boot?
[probably however the shell script wouldn't work then]
If anybody has any further suggestions or even improvement for my
script, I would be grateful
Regards
Steve
--------------8x----------------------------------
From: cobrin.sbd-e@rx.xerox.com (Steve Cobrin @ RX)
Subject: automatic generation of *correct* broadcast address
Message-ID: <1993Jan30.002307.5839@spectrum.xerox.com>
Sender: news@spectrum.xerox.com
Reply-To: cobrin.sbd-e@rx.xerox.com
Organization: Rank Xerox, Welwyn Garden City, UK
Date: Sat, 30 Jan 1993 00:23:07 GMT
How can I ensure that the broadcast address is correctly set in
machines I'm installing?
For example my machine is
IP Address 13.200.0.53
netmask 255.255.252.0
I would like the ifconfig command to automatically correctly set the
broadcast address to 13.200.3.255 instead of 13.200.0.0
I am running Solaris 1.1 (aka SunOS 4.1.3) I understand that this has
been fixed in Solaris 2, but need a fix to last me till we finish
(start?) moving there.
I need the address to be calculated automatically, we have over 300
suns and we want to be able to move machines from one sub-net to
another with the minimum of interaction, ie. IP numbers allocated
perhaps via central RARP server. Although currently we are using 2
sub-nets this will be increased dramatically (to potentially limit to
16 machines per sub-net!?)
One workaround, was to edit every /etc/rc.{boot,local} to calculate the
boadcast address by just forming the one's complement of the netmask
and inclusive or'ing it to the ip address, unfortunately I suddenly
realise that i couldn't think of any non C-programming way of doing
this, anybody know how I could do this with the *standard* sun
utilities.
So to summarise, could anybody:
- send me details of any patch for SunOS 4.1.3's ifconfig
- send me details of any script which would enable me to do
logical arithmetic
Thanks
Steve
Sun Support
Arpa Email address: cobrin.sbd-e@RX.Xerox.COM
+------------------------------------------+---------------------------------+
| Rank Xerox Centre, | Overseas +44 707 38 2276 |
| Site Management and Operations, | UK (0707) 38 2276 |
| | Fax +44 707 38 2418 |
| Bridgefields, Tewin Road, +---------------------------------+
| Welwyn Garden City, Herts, | Xerox Intelnet: 8*668 2276 |
| AL7 1BD, England, GB | Xerox address: Cobrin:SBD-E:RX |
+------------------------------------------+---------------------------------+
--------------8x----------------------------------
Original solution from Dave
#! /bin/csh -f
set nmask = 255.255.252.0
set ipadd = 13.200.0.10
set nm = `echo $nmask | sed 's/\./ /g'`
set ip = `echo $ipadd | sed 's/\./ /g'`
set bc = ""
foreach i (1 2 3 4)
set bc = ($bc `echo "0t$ip[$i]|~0t$nm[$i]&0t255=d" | adb - -`)
end
set bcst = `echo $bc | sed 's/ /\./g'`
echo $bcst
--------------8x----------------------------------
My Bourne shell version
#! /bin/sh
nmask=255.255.252.0
ipadd=13.200.0.10
gen_broadcast() {
nmask=`echo $nmask | sed 's/\./ /g'`
ipadd=`echo $ipadd | sed 's/\./ /g'`
for i in 1 2 3 4
do
set $nmask; eval nm=\$$i
set $ipadd; eval ip=\$$i
x=`echo "0t${ip}|~0t${nm}&0t255=d" | adb - -`
bc=${bc}${bc+.}`echo ${x}`
done
echo $bc
}
gen_broadcast $nmask $ipadd
--------------8x----------------------------------
My final version which we've been using in our /etc/rc.local
This code should be placed just after the following two lines
# set the netmask from NIS if running, or /etc/netmasks for all ether interfaces
ifconfig -a netmask + broadcast + > /dev/null
# the following code should fix the broadcast address
for interface in /etc/hostname.*
do
interface=`expr ${interface} : '/etc/hostname.\(.*\)'`
eval `ifconfig -a | nawk '
BEGIN {
pattern = "^" interface ":" }
$0 ~ pattern {
getline
inet = substr($0, match($0, "inet [0-9.]+"), RLENGTH)
sub(/ /,"=", inet); print inet
netmask = substr($0, match($0, "netmask [a-f0-9]+"), RLENGTH)
sub(/ /,"=", netmask); print netmask
}' interface=$interface`
netmask=`echo $netmask | sed 's/\(..\)\(..\)\(..\)\(..\)/\1 \2 \3 \4/g'`
inet=`echo $inet | sed 's/\./ /g'`
broadcast=
for i in 1 2 3 4; do
set $netmask; eval nm=\$$i
set $inet; eval ip=\$$i
temp=`echo "0t${ip}|~0x${nm}&0t255=d" | adb - -`
broadcast=${broadcast}${broadcast:+.}`echo ${temp}`
done
echo Setting broadcast address of ${interface} to ${broadcast}
ifconfig ${interface} broadcast ${broadcast}
done
--------------8x----------------------------------
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:07:36 CDT