You are on page 1of 12

Scripts for Configuring

IP Multipathing
in Oracle Solaris
Prashant Pilankar, April 2010
Introduction

This tech tip provides a main script and several subscripts that are useful for configuring IP Multipathing in the
Oracle Solaris operating system. The scripts can be modified as needed and can be used to perform the
following tasks:

• Displaying prerequisite information prior to IPMP configuration


• Configuring unique MAC addresses (SPARC systems only)
• Configuring IP addresses
• Configuring the interface as part of a multipath group
• Configuring a test address for the interface
• Verifying link-based IPMP operation
• Making the IPMP configuration persistent across reboot

Note: All the scripts work on both SPARC and x86 machines, with the exception of the script for configuring
unique MAC addresses. That script works only on SPARC systems.

This tech tip covers the following topics:

• Screen Shots From Running the Main Script


• Code for the Scripts
• About the Author

Screen Shots From Running the Main Script

This section contains screen shots that show how to use the main script, ipmpconf, for performing various
tasks.

First, here is a screen shot of the menu provided by the ipmpconf script:

Task 1: Displaying Prerequisite Information Prior to IPMP Configuration


Select option 1 in the script.

Task 2: Configuring Unique MAC Addresses (SPARC Systems Only)

Select option 2 in the script.

Note: Option 2 is capable of configuring unique MAC addresses only on SPARC systems. Its functionality
works fine, but I was not able to provide a screen shot for it because I only have a test Oracle Solaris instance
running on an x86 system with VMware.

Task 3: Configuring IP Addresses

Select option 3 in the script.


Task 4: Configuring the Interface as Part of a Multipath Group

Select option 4 in the script.


Task 5: Configuring a Test Address for the Interface

Select option 5 in the script.


Let's add one more interface as part of the multipath group:

Let's add a test address for the interface:

Task 6: Verifying Link-based IPMP Operation


Select option 6 in the script.

It seems I have missed the task of making the IPMP configuration persistent across reboot. So next I add the
missing task before I reveal the logic of the script.

Task 7: Making This IPMP Configuration Persistent Across Reboot

Select option 7 in the script.


Initially, let's update the /etc/hostname.<interface> file for the e1000g2 interface.

Now let's update the /etc/hostname.<interface> file for the e1000g1 interface:

The following files got created and updated:

/etc/hostname.e1000g2
sys11 netmask + broadcast + group mpgrp-one up addif sys11-test-e1000g2 deprecated
netmask + broadcast + -failover up
/etc/hostname.e1000g1
sys11-data-e1000g1 netmask + broadcast + group mpgrp-one up addif sys11-test-e1000g1
deprecated netmask + broadcast + -failover up

Task 8: Exiting From the Main Script

Select option 8 from the menu.

Code for the Scripts

Now that we have seen how to use the main ipmpconf script, let's have a look at the code for all the scripts.

Here's a link to the ipmp_scripts.zip file, which contains the source code for the main script and the
subscripts.

To use the scripts, do the following:

1. Unzip the .zip file.

2. Place the subscripts in the same directory where you place the main ipmpconf script.

3. Modify the path in the main script as needed, so it points to the directory where you placed the scripts.
(Currently, /export/home/pilankar/ipmp_scripts is used in the script.)

Here are the scripts inline, so you can review them:

First, here's the main ipmpconf script:

#!/usr/bin/bash
#Version 1.0
#Author: Prashant Pilankar
#Email : ppilankar@hotmail.com
# Script for IP Multipathing Configuration in Solaris OS

tput civis # Turn off the cursor

while [ 1 ]
do
echo -e '\E[42;38m' # Set colors: bg=blue, fg=white
clear # Note: colors may be different in xterms
echo -e '\E[44;38m' # bg=red

for n in `seq 6 20`


do
tput cup $n 15
echo " "
done
tput cup 6 25 ; echo -n " ******Please Ensure to be Root Prior to Executing this
Script******* "
echo -ne '\E[45;38m' # bg=magenta
tput cup 8 25 ; echo -n " ***********I P M P C O N F I G U R A T I O N M A I N
M E N U*************** "
echo -e '\E[44;38m' # bg=red

tput cup 9 25 ; echo -n " --------------------------------------------------------"


tput cup 10 25 ; echo -n " |1. Pre-requisites Information for IPMP Configuration
|"
tput cup 11 25 ; echo -n " |2. Configure Unique MAC Addresses (Sparc Only)
|"
tput cup 12 25 ; echo -n " |3. Configure the IP Addresses
|"
tput cup 13 25 ; echo -n " |4. Configure the Interface as Part of a Multipath Group
|"
tput cup 14 25 ; echo -n " |5. Configure a Test Address for the Interface
|"
tput cup 15 25 ; echo -n " |6. Verify Link-based IPMP Operation
|"
tput cup 16 25 ; echo -n " |7. Make Persistent IPMP Settings
|"
tput cup 17 25 ; echo -n " |8. I do not know !
|"
tput cup 18 25 ; echo -n " --------------------------------------------------------"
read case;
#simple case bash structure
# note in this case $case is variable and does not have to
# be named case this is just an example
case $case in
1) /export/home/pilankar/ipmp_scripts/info.sh;;
2) /export/home/pilankar/ipmp_scripts/umac.sh;;
3) /export/home/pilankar/ipmp_scripts/hupdate.sh;;
4) /export/home/pilankar/ipmp_scripts/datanic.sh;;
5) /export/home/pilankar/ipmp_scripts/testnic.sh;;
6) /export/home/pilankar/ipmp_scripts/vlbipmp.sh;;
7) /export/home/pilankar/ipmp_scripts/pipmp.sh;;
8) exit
esac
done

Following are the subscripts that are called from the main ipmpconf script.

Code for info.sh subscript:

#!/usr/bin/bash
#Script to display the current Interface Configuration and OS Release
#Author: Prashant Pilankar
echo
"========================================================================================
==============="
echo " `tput smso` Network Interfaces Configured `tput
rmso`"
echo -e "\033[32m `/usr/sbin/ifconfig -a` \e[m" ; sleep 4
echo " `tput smso` Solaris OS Release `tput rmso`"
echo -e "\033[32m `cat /etc/release` \e[m" ; sleep 4
echo " `tput smso` Contents of /etc/default/mpathd file
`tput rmso`"
echo -e "\033[32m `cat /etc/default/mpathd ` \e[m" ; sleep 4
echo
"========================================================================================
==============="

Code for umac.sh subscript:

#!/usr/bin/bash
#Script to set the local-mac-address? variable to true only for sparc systems
#Author: Prashant Pilankar
echo -e "\033[41m Following is the existing value of the local-mac-address? variable on
sparc system \e[m"
eeprom "local-mac-address?"
echo "Would you like to continue to set the variable to true (y/n)?"
read f
if [ $f = y ]
then
eeprom "local-mac-address?=true" ; echo "now the variable value is set to" ; eeprom
"local-mac-address?" ; sleep 5
else
echo "bye for now " ; sleep 4 ; exit
fi

Code for hupdate.sh subscript:

#!/usr/bin/bash
#Script to update the /etc/inet/hosts file for ipmp
#Author: Prashant Pilankar
echo -e "\033[44m Add the data and test IP addresses to the /etc/inet/hosts file for the
sake of clarity \e[m"
echo "Please input the following information"
echo "IP Address"
echo "Associated hostname"
echo "Comment"
echo "==================================================================="
echo -e "\033[41m Example : 192.168.1.1 sys11 # Data address for hme0 \e[m"
echo "==================================================================="
read a b c
echo $a $b $c >> /etc/inet/hosts
echo
echo -e "\033[45m Following are the contents of the /etc/inet/hosts file \e[m"
cat /etc/inet/hosts ; sleep 5

Code for datanic.sh subscript:

#!/usr/bin/bash
#Script to configure a interface as part of a Multipath group
#Author: Prashant Pilankar
echo -e "\033[41m This script assumes the /etc/inet/hosts & /etc/inet/netmasks file's are
updated \e[m"
echo -e "\033[41m Please input the following information \e[m"
echo "Interface Name"
echo "Name of the Multipath group"
echo "Hostname associated with the interface"
echo "==================================================================="
echo -e "\033[44m Example : hme0 mpgrp-one sys11 \e[m"
echo "==================================================================="
read a b c

echo "Is the interface already plumbed and up (y/n)?"


read f
if [ $f = y ]
then
ifconfig $a group $b &> /dev/null ; ifconfig -a ; sleep 6
else
ifconfig $a plumb $c netmask + broadcast + &> /dev/null ; ifconfig $a group $b up
&> /dev/null ; ifconfig -a ; sleep 6
fi

Code for testip.sh subscript:

#!/usr/bin/bash
#Script to configure a interface as part of a Multipath group
#Author: Prashant Pilankar
echo -e "\033[44m This script assumes the /etc/inet/hosts file is updated \e[m"
echo -e "\033[44m Please input the following information \e[m"
echo "Interface Name"
echo "Test Address of the Interface"
echo "==================================================================="
echo -e "\033[41m Example : hme0 192.168.1.51 \e[m"
echo "==================================================================="
read a b
ifconfig $a addif $b deprecated netmask + broadcast + -failover up &> /dev/null ; echo
"===========================" ; ifconfig -a ; sleep 5

Code for vlbipmp.sh subscript:

#!/usr/bin/bash
#Script to Verify Link-based IPMP Operation
#Author: Prashant Pilankar
echo -e "\033[44m Please input the following Information to Verify Link-based IPMP
Operation \e[m"
echo "Interface Name"
echo "=========================================="
echo -e "\033[41m Example : hme0 \e[m"
echo "=========================================="
read a
if_mpadm -d $a ; echo -e "\033[45m Following is the NIC Configuration after the forced
Failover \e[m" ; ifconfig -a
echo " `tput smso` Recent update to /var/adm/messages file `tput rmso`
" ; tail -2 /var/adm/messages
echo "========Please Wait forcing Failback===========" ; sleep 6
if_mpadm -r $a ; echo -e "\033[45m Following is the NIC Configuration after the forced
Failback \e[m" ; ifconfig -a ; sleep 6
echo " `tput smso` Recent update to /var/adm/messages file `tput rmso`
" ; tail -2 /var/adm/messages
echo "========================================================"

Code for pipmp.sh subscript:

#!/usr/bin/bash
#This script makes the IPMP Settings persistent across reboot
#Author: Prashant Pilankar
echo -e "\033[44m This script updates the /etc/hostname.<interface> files for
Persistent IPMP Settings \e[m"
echo -e "\033[44m Please input the following information for each \e[m"
echo -e "\033[44m Physical Interface part of the IPMP group \e[m"
echo "Hostname Associated With the Physical Interface"
echo "IPMP groupname"
echo "Hostname Associated with the Test Interface"
echo "============================================================"
echo -e "\033[45m Example : hme0 sys11 mpgrp-one sys11-test-hme0 \e[m"
echo "============================================================"
read a b c d
touch /etc/hostname.$a
echo "`echo $b` netmask + broadcast + group `echo $c` up addif `echo $d` deprecated
netmask + broadcast + -failover up" > /etc/hostname.$a
echo -e "\033[45m Following are the updates made to the file /etc/hostname.`echo $a`
\e[m"
cat /etc/hostname.$a ; sleep 5

About the Author

Prashant Shashikant Pilankar has been a Solaris System Administrator for nearly nine years. He has experience
in Veritas Volume Manger and Basic Veritas Cluster and Basic Veritas NetBackup from Symantec, plus several
IT certifications, including the Solaris OS, Veritas, Oracle, Cisco, and Microsoft technology.

You might also like