From this documentation provided by SmartOS

We can enable DHCP client on global zone by create a SMF service which start will dhcp client on network interface at start up.

Create SMF Service


Create SMF service manifest xml file under /opt/custom/smf (SmartOS SMF will automatically detect and run it at startup) This script will wait for two dependency to start up first before it runs (network and filesystem)

<?xml version=’1.0′?>
<!DOCTYPE service_bundle SYSTEM ‘/usr/share/lib/xml/dtd/service_bundle.dtd.1′>
<service_bundle type=’manifest’ name=’export’>
<service name=’smartos/setup’ type=’service’ version=’0′>
<create_default_instance enabled=’true’/>
<dependency name=’net-physical’ grouping=’require_all’ restart_on=’none’ type=’service’>
<service_fmri value=’svc:/network/physical’/>
<dependency name=’filesystem’ grouping=’require_all’ restart_on=’none’ type=’service’>
<service_fmri value=’svc:/system/filesystem/local’/>
<exec_method name=’start’ type=’method’ exec=’/opt/custom/scripts/ %m’ timeout_seconds=’0’/>
<exec_method name=’stop’ type=’method’ exec=’/opt/custom/scripts/ %m’ timeout_seconds=’0’/>
<property_group name=’startd’ type=’framework’>
<propval name=’duration’ type=’astring’ value=’transient’/>
<stability value=’Unstable’/>
<loctext xml:lang=’C’>SmartOS Ad Hoc Setup Script</loctext>

Create setup script


this setup scripts will set hostname and use ipadm (ifconfig replacement) to create an interface and set dhcp on it.

# Simple Ad Hoc SmartOS Setup Service
#enable debug
set -o xtrace
PATH=/usr/sbin:/usr/bin:/opt/custom/bin:/opt/custom/sbin; export PATH

if [ $1 == “start” ]
hostname “smartos01” && hostname > /etc/nodename
ipadm create-if e1000g0
ipadm create-addr -T dhcp e1000g0/dhcp
exit 0