VMWare VI3 - Sample Script to Configure the Console
#!/bin/sh
- VI3 Server Customization v1.0
- Jason M. Langone
- Veni, vidi, vici
- Remove default network configuration
- Ask if internal or DMZ?
- INTERNAL BLADE VERSION =-=-=-mkdir /root/PostInstall
echo “Deleting current network configuration” >> /root/PostInstall/PostInstall.log
echo ———————————- Service Console Configuration —————-echo Deleting current network configuration
echo …...................................
esxcfg-vswitch vSwitch0 -D “VM Network”
esxcfg-vswif -D
esxcfg-vswif -d vswif0
esxcfg-vswitch vSwitch0 -D “Service Console”
esxcfg-vswitch vSwitch0 -U vmnic0
esxcfg-vswitch vSwitch0 -d #———————-
echo Enter hostname in FQDN format:
read vi3host
echo Enter hostname in short format:
read vi3short
echo Enter Service Console IP Address:
read vi3scip
echo Enter Service Console Subnet Mask:
read vi3scsm
echo Enter Service Console Default Gateway:
read vi3scdg
echo DNS..Enter Domain
read vi3search
echo DNS..Enter Primary DNS Server IP:
read vi3dnsp
echo DNS..Enter Secondary DNS Server FQDN:
read vi3dnss
echo NTP..Enter Primary NTP Server FQDN:
read vi3ntpa
echo NTP..Enter Secondary NTP Server FQDN:
read vi3ntpb
echo NTP..Enter Tertiary NTP Server FQDN:
read vi3ntpc
echo ———————————————————————————-
echo You have configured $vi3host with the following details:
echo Service Console IP Address will be $vi3scip
echo Service Console Subnet Mask will be $vi3scsm
echo Service Console Default Gateway will be $vi3scdg
echo DNS Details:
echo Domain: $vi3search
echo Primary DNS: $vi3dnsp
echo Secondary DNS: $vi3dnss
echo NTP Details:
echo Primary: $vi3ntpa
echo Secondary: $vi3ntpb
echo Tertiary: $vi3ntpc
echo ———————————————————————————-
#esxcfg-vswitch vSwitch0 -D “VM Network”
#esxcfg-vswitch -U vmnic0 vSwitch0
#esxcfg-vswitch -U vmnic1 vSwitch0
#esxcfg-vswif -d vswif0
#esxcfg-vswitch -d vSwitch0
#service mgmt-vmware restart
echo “Configuring local VMFS ...” >> /root/PostInstall/PostInstall.log
echo Configuring local VMFS...
#export vi3part=‘fdisk -l /dev/cciss/c0d0 | grep fb | sed -e “s/\/dev\/cciss\/c0d0p\(.\).*/\1/”’
vmkfstools -C vmfs3 vmhba0:0:0:3 -S $vi3short\-vmfslocal
echo “Configuring Hostname …” >> /root/PostInstall/PostInstall.log
echo Configuring Hostname…
hostname $vi3host
cp /etc/sysconfig/network /etc/sysconfig/network.bak
rm /etc/sysconfig/network
echo NETWORKING=yes >> /etc/sysconfig/network
echo GATEWAYDEV=vswif0 >> /etc/sysconfig/network
echo HOSTNAME=$vi3host >> /etc/sysconfig/network
echo “Reconfiguring Certificate …” >> /root/PostInstall/PostInstall.log
echo Reconfiguring Certificate…
mv /etc/vmware/ssl/rui.crt /etc/vmware/ssl/orig.rui.crt
mv /etc/vmware/ssl/rui.key /etc/vmware/ssl/orig.rui.key
echo “Configuring DNS ...” >> /root/PostInstall/PostInstall.log
echo Configuring DNS...
cat search $vi3dnssearch >> /etc/resolv.conf
cat $vi3dnsp >> /etc/resolv.conf
cat $vi3dnss >> /etc/resolv.conf
echo …DONE!
echo “Configuring NTP ...” >> /root/PostInstall/PostInstall.log
- BOTCHED
echo Configuring NTP...
cat “#company NTP servers” >> /etc/ntp/ntp.conf
cat server $vi3ntpa >> /etc/ntp/ntp.conf
cat server $vi3ntpa >> /etc/ntp/ntp.conf
cat server $vi3ntpa >> /etc/ntp/ntp.conf
cat “#restrict everything” >> /etc/ntp/ntp.conf
cat “restrict default ignore” >> /etc/ntp/ntp.conf
cat “#allow access via the loopback network” >> /etc/ntp/ntp.conf
cat “restrict 127.0.0.1” >> /etc/ntp/ntp.conf
cat “#allow access to the company NTP servers” >> /etc/ntp/ntp.conf
cat “#must use numeric addresses” >> /etc/ntp/ntp.conf
cat “restrict 172.21.200.19” >> /etc/ntp/ntp.conf
cat “restrict 172.21.200.20” >> /etc/ntp/ntp.conf
cat “restrict 172.21.135.231” >> /etc/ntp/ntp.conf
cat “#use the local clock tweaked to stratum 10” >> /etc/ntp/ntp.conf
cat “#as a last resort if the xxx NTP servers” >> /etc/ntp/ntp.conf
cat “#are unreachable” >> /etc/ntp/ntp.conf
cat “server 127.127.1.0” >> /etc/ntp/ntp.conf
cat “fudge 127.127.1.0 stratum 10” >> /etc/ntp/ntp.conf
cat “#specify the location of the drift file” >> /etc/ntp/ntp.conf
cat “#this contains the systemic frequency” >> /etc/ntp/ntp.conf
cat “#correction for our hardware” >> /etc/ntp/ntp.conf
cat “driftfile /var/lib/ntp/drift” >> /etc/ntp/ntp.conf
esxcfg-firewall —enableService ntpClient
echo …DONE!
echo “Reconfiguring Service Console NIC...” >> /root/PostInstall/PostInstall.log
echo Reconfiguring Service Console NIC...
cp /etc/vmware/esx.conf /tmp/post/esx.conf.bak
echo Create Kernel Switch…
esxcfg-vswitch -a vKernel
echo …DONE!
echo Bind NICs to Kernel Switch…
esxcfg-vswitch vKernel -L vmnic0
esxcfg-vswitch vKernel -L vmnic3
echo …DONE!
echo Create ServiceConsole Port Group…
esxcfg-vswitch -A “Service Console” vKernel
esxcfg-vswitch vKernel -p “Service Console” -v 136
echo …DONE!
echo Configure ServiceConsole IP Details…
esxcfg-vswif -a vswif0 -p “Service Console” -i $vi3scip -n $vi3scsm #route add default gw $vi3scdg netmask 0.0.0.0 #route del default gw $vi3scdg netmask ….
echo “GATEWAY=$vi3scdg” >> /etc/sysconfig/network
service mgmt-vmware restart
echo …DONE!
echo ———————————————————————————-
echo Please reboot!
reboot
exit 0
- Jason Langone
Commenting is closed for this article.

2007 Systems Architech.