X

News, tips, partners, and perspectives for the Oracle Solaris operating system

ipadm

Solaris 11 introduces a new command for administering IP interfaces - ipadm. ipadm is an upgrade over the venerable ifconfig and unlike ifconfig, changes made with ipadm persist across reboots. There's no longer a need to fuddle with configuration files.

ifconfig hasn't gone away, but I've been trying to wean myself off of it in favor of the new ipadm command.







An initial look at the usage command for ipadm shows a much cleaner interface that introduces a subcommand:

bleonard@solaris:~$ ipadm
usage: ipadm <subcommand> <args> ...

create-if

[-t] <interface>

disable-if

-t <interface>

enable-if

-t <interface>

delete-if

<interface>

show-if

[[-p] -o <field>,...] [<interface>]

set-ifprop

[-t] -p <prop>=<value[,...]> -m <protocol> <interface>

reset-ifprop

[-t] -p <prop> -m <protocol> <interface>

show-ifprop

[[-c] -o <field>,...] [-p <prop>,...]

[-m <protocol>] [interface]

create-addr

[-t] {-T static <static_args> | -T dhcp <dhcp_args> |

-T addrconf <addrconf_args>} <addrobj>

static_args = <[-d] -a {local|remote}=addr[/prefixlen]>

dhcp_args = <[-w <seconds> | forever]>

addrconf_args = <[-i interface-id]

[-p {stateful|stateless}={yes|no}]>

down-addr

[-t] <addrobj>

up-addr

[-t] <addrobj>

disable-addr

-t <addrobj>

enable-addr

-t <addrobj>

refresh-addr

[-i] <addrobj>

delete-addr

[-r] <addrobj>

show-addr

[[-p] -o <field>,...] [<addrobj>]

set-addrprop

[-t] -p <prop>=<value[,...]> <addrobj>

reset-addrprop

[-t] -p <prop> <addrobj>

show-addrprop

[[-c] -o <field>,...] [-p <prop>,...] <addrobj>

set-prop

[-t] -p <prop>[+|-]=<value[,...]> <protocol>

reset-prop

[-t] -p <prop> <protocol>

show-prop

[[-c] -o <field>,...] [-p <prop>,...] [protocol]

Compare this with the overly complex ifconfig command:

bleonard@solaris:~$ ifconfig
usage: ifconfig <interface> | -a[ 4 | 6 | D ][ u | d ][ Z ]

[ <addr_family> ]

[ <address>[/<prefix_length>] [ <dest_address> ] ]

[ set [ <address>][/<prefix_length>] ] [ <address>/<prefix_length>] ]

[ destination <dest_address> ]

[ addif <address>[/<prefix_length>] [ <dest_address> ] ]

[ removeif <address>[/<prefix_length>] ]

[ arp | -arp ]

[ auto-revarp ]

[ broadcast <broad_addr> ]

[ index <if_index> ]

[ metric <n> ] [ mtu <n> ]

[ netmask <mask> ]

[ plumb ] [ unplumb ]

[ preferred | -preferred ]

[ private | -private ]

[ local | -local ]

[ router | -router ]

[ subnet <subnet_address>]

[ trailers | -trailers ]

[ token <address>/<prefix_length> ]

[ tsrc <tunnel_src_address> ]

[ tdst <tunnel_dest_address> ]

[ auth_algs <tunnel_AH_authentication_algorithm> ]

[ encr_algs <tunnel_ESP_encryption_algorithm> ]

[ encr_auth_algs <tunnel_ESP_authentication_algorithm> ]

[ up ] [ down ]

[ xmit | -xmit ]

[ modlist ]

[ modinsert <module_name@position> ]

[ modremove <module_name@position> ]

[ ipmp ]

[ group <groupname>] | [ group ""]

[ deprecated | -deprecated ]

[ standby | -standby ]

[ failover | -failover ]

[ zone <zonename> | -zone ]

[ usesrc <interface> ]

[ all-zones ]
or

ifconfig <interface> | -a[ 4 | 6 | D ] [ u | d ]

auto-dhcp | dhcp

[ wait <time> | forever ]

[ primary ]

start | drop | ping | release | status | inform

However, one thing that initially tripped me up in my usage of ipadm was the introduction of the addrobj.  An addrobj
is just a user supplied name for an address configured on a network
interface that can later be used to reference that address. It's comprised of 2 parts, the network interface on which the
address is configured and a string of your liking, separated by a
slash. Generally the string you select would describe the address
(v4dhcp, v6static, etc.):

addrobj = <network interface>/<any string>

So, for example:

addrobj = e1000g0/v4static

This addrobj is then used to reference the address. The ipadm subcommands that work with an an addrobj all have "addr" in their name. Likewise, the ipadm subcommands that work with an interface all have "if" in their name.

Typically, the two most common things I do with ifconfig are to configure addresses on my interfaces and list those addresses. Here are the ifconfig commands I use and their ipadm equivalents.

Note, if you plan on using ipadm to configure your network interfaces, disable network/nwam and enable network/physical:default:

bleonard@solaris:~$ svcs nwam physical:default
STATE          STIME    FMRI
disabled       11:32:38 svc:/network/physical:nwam
online         11:32:55 svc:/network/physical:default

Configuring An Interface

Old School

Bringing up an interface using ifconfig is pretty straight-forward. The big drawback is that the interface configuration will not persist across a reboot:

bleonard@solaris:~$ sudo ifconfig e1000g0 plumb 10.0.2.15/24 up

New School

The new ipadm command is a little more esoteric, however, its settings do persist across a reboot:

bleonard@solaris:~$ sudo ipadm create-addr -T static -a 10.0.2.15/24 e1000g0/v4static

This is the command that has taken me the longest to get used to
because there appears to be so much going on here. The ifconfig command doesn't have the option flags (-T and -a in my example) - which makes the usage cleaner. For example, ifconfig infers I want a static address because I've passed it an IP address. The ipadm command is also longer than ifconfig because we're now assigning our address a name (e1000g1/v4static).

List My Interfaces

Old School

To see what IP addresses I have configured on my network interfaces I traditionally used:

bleonard@solaris:~$ ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1

inet 127.0.0.1 netmask ff000000
e1000g0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 4

inet 10.0.2.15 netmask ffffff00 broadcast 10.0.2.255
lo0: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1

inet6 ::1/128
e1000g0: flags=20002000840<RUNNING,MULTICAST,IPv6> mtu 1500 index 4

inet6 ::/0

The output is a bit messy, but I'm very accustomed to it.

New School

With ipadm:

bleonard@solaris:~$ ipadm show-addr
ADDROBJ TYPE STATE ADDR
lo0/v4 static ok 127.0.0.1/8
e1000g0/v4static static ok 10.0.2.15/24
lo0/v6 static ok ::1/128

Note, if you see an addrobj that is listed as <interface>/?, that address was configured on the interface by an application that did not use
libipadm APIs.

Here's a nice table comparing the ifconfig Command Options and ipadm Command Options.

Because I know you're curious, ipadm uses /etc/ipadm/ipadm.conf as its persistence store:

bleonard@solaris:~$ cat /etc/ipadm/ipadm.conf 
#
# CDDL License...
#
# DO NOT EDIT OR PARSE THIS FILE!
#
# Use the ipadm(1m) command to change the contents of this file.
_ifname=e1000g0;_family=2;
_ifname=e1000g0;_family=26;
_ifname=e1000g0;_aobjname=e1000g0/v4static;_ipv4addr=10.0.2.15,;up=yes;
_ifname=e1000g0;_aobjname=e1000g0/v4static;prefixlen=24;

So, that's my brief introduction to ipadm. Here are some other references that you may find useful:


Join the discussion

Comments ( 6 )
  • Eli Kleinman Wednesday, May 25, 2011
    Is it possible to configure ipmp with ipadm?
  • jelmd Friday, May 27, 2011
    You should add a note, that if one switches from nwam to network:physical, the ipfilter policy switches to none and thus will not pick up automatically /etc/ipf/ipf.conf as one normally would expect ...
  • guest Monday, May 30, 2011
    The ifconfig command doesn't require 2 steps to plumb and configure an interface. Try "ifconfig bge2 plumb 192.168.99.99 up".
    I still prefer ifconfig for it's simplicity and succinctness, but ipadm does have much prettier output. It's a little like comparing vi and MS word.
  • W Brian Leonard Tuesday, May 31, 2011
    guest, thanks for the tip on ifconfig. I've updated the entry.
  • Nathan Tuesday, December 27, 2011

    @John Warburton

    I tend to agree. I would recommend not just puppet but mcollective on top. This will allow you to 'run' commands on many/all nodes based on their facts.


  • guest Monday, October 20, 2014

    Hello

    Please help me

    in solaris 10

    ifconfig e1000g0 plumb 192.168.1.2 netmask + broadcast + group ipmp0 up addif 192.168.1.3 netmask + broadcast + deprecated -failover up

    # ifconfig e1000g1 plumb 192.168.1.4 netmask + broadcast + deprecated -failover group ipmp0 up

    how we can configure this in solaris 11.

    i mean how to use ipadm commad for the same

    please help its urgent


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha