Hi
I am trying to run a script centrally that will go out and set the network management ip address on all my Sun boxes running Solaris. We have decided that the network management address will be the boxes main IP address but the first octet as a 172 rather than a 10, so for example ifconfig -a will look like this
Code:
[root@a-server # ifconfig -a
lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
dmfe0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 10.36.14.45 netmask ffff0000 broadcast 10.32.255.255
ether 0:3:ba:5:a8:1a
the command to set the management IP address locally on these machines would be
Code:
/usr/sfw/bin/ipmitool -I bmc lan set 1 ipaddr 172.36.14.45
so I have written a little script that and will do a
sed replace against the output of ifconfig, switch the 10 for a 172 blah blah and throw the output into the ipmitool command listed above, and when run locally on the target machine it works like a dream ...here it is
Code:
/usr/sfw/bin/ipmitool -I bmc lan set 1 ipaddr `ifconfig -a | grep inet | grep -v 127.0.0.1 | head -1 | sed s/^.*inet\ // | sed s/\ netmask.*$// | sed s/^10/172/`
So as I say, rather than running this on every box locally, ive written another script that goes out to all machines (listed in a file called serverlist) using SSH and sets it remotely, the problem is, when I do this, the embedded ifconfig/
sed bit seems to run locally on my central servers IP address and not on the target box, so in other words it sets the remote boxes management IP to my central boxes main IP (with the 10 switched for a 172) ....I just cant seem to get it to properly embed and run the command on the target box
here is my script
Code:
#!/bin/ksh
for hostname in `cat /data/serverlist`
do
echo $hostname
ssh $hostname "/usr/sfw/bin/ipmitool -I bmc lan set 1 ipaddr `ifconfig -a | grep inet | grep -v 127.0.0.1 | head -1 | sed s/^.*inet\ // | sed s/\ netmask.*$// | sed s/^10/172/`"
done
When run ...
Code:
[root@central-server] # ./configure.sh
a-server
Setting LAN IP Address to 172.1.0.45 << this should be 172.36.14.45
does anybody know why this is happening....ive tried changing the " for a ' but then it stops working altogether
any help would be greatly appreciated