Riaan's SysAdmin Blog

My tips, howtos, gotchas, snippets and stuff. Use at your own risk!

Solaris

Solaris ipadm show-prop and returning only current value

A lot has been written about Solaris 11 networking changes and how to manage it with different commands. This is just a quick note on something specific to what I was trying. Previous versions of Solaris I could do a quick ndd command to get or set a value. For example:

# ndd -get /dev/tcp tcp_smallest_anon_port
9000

And yes above ndd command still works in Solaris 11.

In Solaris 11 most documentation would indicate doing the following:

# ipadm show-prop -p smallest_anon_port tcp
PROTO PROPERTY              PERM CURRENT      PERSISTENT   DEFAULT      POSSIBLE
tcp   smallest_anon_port    rw   9000         9000         32768        1024-65500

Above is fine if you are checking something but what if you need to just return the current value. You can of course do some string manipulation but if you dig a little deeper ipadm can return exactly what you want as follow. In my case I wanted to have a reliable check so my puppet manifest would not set the value again if already correct(using exec/onlyif in puppet).

Returning only the value with ipadm works as follow:

# ipadm show-prop -o CURRENT -c -p smallest_anon_port tcp
9000

I plan to add more about puppet and Solaris in general later but here is the ipadm check in the puppet manifest for reference.

exec { "ipadm smallest_anon_port tcp":
  command     => "ipadm set-prop -p smallest_anon_port=9000 tcp",
  path        => $execPath,
  onlyif      => "ipadm show-prop -o CURRENT -c -p smallest_anon_port tcp | grep -v 9000"
}

admin

Bio Info for Riaan