[Casper] Script to turn off IPv6

Ernst, Craig S. ERNSTCS at uwec.edu
Mon Dec 22 13:54:48 PST 2008


I will! Thanks Miles! Just had a request from the network guys to turn it off just last week.

Craig E

On 12/22/08 3:49 PM, "Miles Leacy" <miles.leacy at themacadmin.com> wrote:

I didn't see this one in the resource kit, and it took me some tinkering to get it just right.  I hope some of you get some use out of this script (I'm attaching a zipped file just in case your mail reader, or any mail servers between you and I, mangle the text below).

This script can be part of a configuration (make sure it's run "at reboot"), a policy for already-deployed systems, or run ad-hoc out of Casper Remote.

#!/bin/bash

##### HEADER BEGINS #####
# scr_sys_turnOffIPv6.bash
#
# Created 20081222 by Miles A. Leacy IV
# miles.leacy at themacadmin.com
# Modified 20081222 by Miles A. Leacy IV
# Copyright 2008 Miles A. Leacy IV
#
# This script may be copied and distributed freely as long as this header remains intact.
#
# This script is provided "as is".  The author offers no warranty or guarantee of any kind.
# Use of this script is at your own risk.  The author takes no responsibility for loss of use,
# loss of data, loss of job, loss of socks, the onset of armageddon, or any other negative effects.
#
# Test thoroughly in a lab environment before use on production systems.
# When you think it's ok, test again.  When you're certain it's ok, test twice more.
#
# This script turns off IPv6 on all network interfaces present.
# Run as an "at reboot" script when imaging with Casper.
#
##### HEADER ENDS #####

# first, change $IFS environment variable to allow a "for" statement to capture an entire line.
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")

# get list of network services on system

for i in $( networksetup -listallnetworkservices )
  do

# skip descriptive line in networksetup output

descriptive=`echo $i|awk {'print $1'}`
if [ "$descriptive" != "An" ];then

# if there is no asterix before the service name, turn IPv6 off via networksetup
has_asterix=`echo $i|grep ^*`

if [ $? -ne 0 ];then

networksetup -setv6off $i; echo "IPv6 disabled on" $i

else

# if there is an asterix before the service name, strip the asterix, then run networksetup
# using the asterix-free service name

disabled_service=`echo $has_asterix|awk -F* {'print $2'}`
networksetup -setv6off $disabled_service; echo "IPv6 disabled on" $disabled_service

fi
fi

done

echo "IPv6 has been turned off for all network services."

# restore $IFS
IFS=$SAVEIFS

exit 0

----------
Miles A. Leacy IV

? Certified System Administrator 10.4
? Certified Technical Coordinator 10.5
? Certified Trainer
Certified Casper Administrator
----------
voice: 1-347-277-7321
miles.leacy at themacadmin.com
www.themacadmin.com <http://www.themacadmin.com>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.jamfsoftware.com/pipermail/casper/attachments/20081222/9dd4b9a0/attachment.html 


More information about the Casper mailing list