Static IP on multiple NICs in OpenIndiana with NWAM

I wanted to set one of the NICs on my OI box to have a static since it's got a direct connection to my ESX box, bypassing any switches, and directly linked to a VM on that machine. I routinely transfer large chunks of data (1-20GB files) from that VM to my OI box, so I wanted to completely move that off of my main network. The VM is a Windows box, and I have the NIC set statically to 192.168.20.1/30 and wanted to set the OI box to .2. However, I couldn't find a simple way to do it with ifconfig, and everything I found suggested disabling the NWAM service and switching to the old way of doing things, which is bad. Apparently.

tl;dr

At any rate, disabling the service that was in charge of how my NICs were configured didn't seem like a good idea with a headless box, only accessible via SSH. So, I kimmed some pages about what the NWAM service does and how to use it I started looking for better examples of how to use it and stumbled across this page. I figured out how to create my own profile with one static, and one DHCP link.

In order to do this you need to use nwamcfg to create a new Network Configuration Profile , and then setup both NICs in the profile as Network Configuration Units with their desired options, then activate the profile.

First, run nwamcfg under root, then do:

$ nwamcfg  
nwamcfg> create ncp profile   #Create the profile  
nwamcfg:ncp:profile> create ncu phys nic0 #Add the layer 2 config for nic0  
Created ncu 'nic0'. Walking properties ...  
# Set prioritized so that it starts at boot.  
activation-mode (manual) [manual|prioritized]> prioritized  
# Leave default for enabled.  
enabled (true) [true|false]>  
# 0 for ethernet (802.3) 1 for wifi (802.11)  
priority-group> 0  
# exclusive means only 1 NCU (NIC) in the group  
# shared means any of the NCUs can be active  
# all means all of the NCUs must be available to be active  
priority-mode [exclusive|shared|all]> shared  
# Leave the default MAC  
link-mac-addr>  
# Configures autopush settings, modules to be added I dunno...  
link-autopush>  
# Set MTU, I have jumbo frames  
link-mtu> 9126  
nwamcfg:ncp:profile:ncu:nic0> end  
Committed changes  
# Create the Layer 2 settings for nic1  
nwamcfg:ncp:profile> create ncu phys nic1  
Created ncu 'nic1'. Walking properties ...  
activation-mode (manual) [manual|prioritized]> prioritized  
enabled (true) [true|false]>  
priority-group> 0  
priority-mode [exclusive|shared|all]> shared  
link-mac-addr>  
link-autopush>  
link-mtu> 9126  
nwamcfg:ncp:profile:ncu:nic1> end  
Committed changes  
# Create layer 3 settings for nic0  
nwamcfg:ncp:profile> create ncu ip nic0  
Created ncu 'nic0'. Walking properties ...  
enabled (true) [true|false]>  
# Select which IP version you want, both here  
ip-version (ipv4,ipv6) [ipv4|ipv6]>  
ipv4-addrsrc (dhcp) [dhcp|static]> static  
# Use CIDR notation  
ipv4-addr> 192.168.2.0.2/30  
# Set your default route, blank cause I don't need one here  
ipv4-default-route>  
# Set ipv6, options, not using it, not set.  
ipv6-addrsrc (dhcp,autoconf) [dhcp|autoconf|static]>  
ipv6-default-route>  
nwamcfg:ncp:profile:ncu:nic0> end  
Committed changes  
# Configure layer 3 settings for nic1  
nwamcfg:ncp:profile> create ncu ip nic1  
Created ncu 'nic1'. Walking properties ...  
enabled (true) [true|false]>  
ip-version (ipv4,ipv6) [ipv4|ipv6]>  
ipv4-addrsrc (dhcp) [dhcp|static]>  
ipv4-default-route>  
ipv6-addrsrc (dhcp,autoconf) [dhcp|autoconf|static]>  
ipv6-default-route>  
nwamcfg:ncp:profile:ncu:nic1> end  
Committed changes  
nwamcfg:ncp:profile> end  
nwamcfg> end  
  
# Enable the profile  
$ nwamadm enable -p ncp profile

Edit (3/24/2012): Thanks for the correction on the last command, Jasper.