Static IP in Solaris

Anand Bisen bio photo By Anand Bisen Comment

Solaris 11 provide two different mechanisms for IP management. The default being physical:nwam which automagically handles almost everything. If nwam meets your need there should be no need for reading any further. The alternative to physical:nwam is physical:default where you have complete control over each and every setting.

Step I: Disable “nwam” and Enable “default” First step is always to turn off the default network/physical:nwam SMF service and turn on network/physical:default service.:

# svcadm disable network/physical:nwam
# svcadm enable network/physical:default

This would reset all of the existing network settings. And if you are connected to the Solaris server via SSH interface you will loose the connectivity.

Step II: Create IP Interface and Assign an IP Address to it To query the physical interface you could use dladm, and for querying the IP interfaces you would use ipadm.::

# dladm show-phys
LINK         MEDIA                STATE      SPEED  DUPLEX    DEVICE
e1000g0      Ethernet             unknown    1000   full      e1000g0

# ipadm show-if
lo0        ok       -m-v------46   ---

As you can see from the output above that there is a hardware (Physical) interface e1000g0 present in the system, but there is no corresponding IP interface defined for that physical interface. And the only IP interface that is defined by default is lo0, which represents loopback interface.

You could additionally issue ipadm show-addr command to query the IP address assigned to these interfaces.::

# ipadm show-addr
ADDROBJ           TYPE     STATE        ADDR
lo0/v4            static   ok 
lo0/v6            static   ok           ::1/128

Next we would create an IP interface and define a static IP address to it by calling ipadm::

# ipadm create-if e1000g0
# ipadm show-if
lo0        ok       -m-v------46        ---
e1000g0    ok       bm--------46        -46

# ipadm create-addr -T static -a e1000g0/v4
# ipadm show-addr
ADDROBJ           TYPE     STATE        ADDR
lo0/v4            static   ok 
e1000g0/v4        static   ok 
lo0/v6            static   ok           ::1/128

Step III: Configure default Gateway Once IP address is defined on the first interface, more often than not the next step would be to set a default route. This is achieved by calling route command. To check the existing persistent route you would execute route -p show:

# route -p show
No persistent routes are defined

# route -p add default
add net default: gateway
add persistent net default: gateway

# route -p show
persistent: route add default

Step IV: Edit “nssswitch.conf” and configure DNS Name Servers Once the gateway is defined the next step in most cases is to update the nssswitch.conf file to ensure that the lookup for hostname also includes DNS search in addition to the statically defined hosts in /etc/hosts file. For that modify /etc/nssswitch.conf file as follows::

# Replace the following line with
# hosts:      files
hosts:      files dns mdns

And the last step would be to define the DNS name servers. Apparently there is no command line interface for managing name servers and still requires manually editing /etc/resolv.conf file. The resolve.conf file should look something like::

# cat /etc/resolv.conf

Step V: Define a hostname You may want to do this earlier, but order does not really matter. Once everything is configured one last change you may want to make is, to define a more logical hostname (than the default solaris) of your newly configured host.::

# svccfg -s svc:/system/identity:node setprop \
        config/nodename = new-node-name
comments powered by Disqus