Thursday, December 27, 2012

Manual wireless connection

For the sake of absolute simplicity I'll assume here the DefaultFixed NCP.
My wired and wireless interfaces have been respectively renamed to e0 and w0.

In this scenario, to manually establish a Wi-Fi connection is not that difficult.
The best of all is that you can do it with a few CLI commands.

You may need to double-check what wireless networks are in range:

# dladm scan-wifi
...

To connect to a secure wireless network you need to define a security object.
This object will typically store a WPA2 shared secret key:

# dladm create-secobj -c wpa secobj-W0
provide value for 'secobj-W0':

******************************************************
confirm value for 'secobj-W0':

******************************************************

# dladm show-secobj
OBJECT               CLASS
secobj-W0            wpa

 
Now it shall be possible to successfully connect to the proected wireless network.
Specify the wireless network, the security object and the wireless interface:

# dladm connect-wifi -e W0 -k secobj-W0 w0

If everything went well you'll get something such as:

# dladm show-wifi
LINK       STATUS       ESSID     SEC    STRENGTH   MODE   SPEED
w0         connected    W0        wpa    excellent  g      54Mb

 
# dladm show-link
LINK                CLASS     MTU    STATE    OVER
w0                  phys      1500   up       --
e0                  phys      1500   unknown  --

 
We have just enabled the link w0 corresponding to the secure wireless network W0.
Now just conclude the usual network configuration over the link w0.
For instance:
 
# ipadm show-if
IFNAME     CLASS    STATE    ACTIVE OVER
lo0        loopback ok       yes    --


# ipadm create-ip w0
# ipadm show-if

IFNAME     CLASS    STATE    ACTIVE OVER
lo0        loopback ok       yes    --
w0         ip       down     no     --


# ipadm create-addr -T dhcp -h vbox-1 w0/v4
# ipadm show-addr

lo0/v4            static   ok           127.0.0.1/8
w0/v4             dhcp     ok           10.0.0.7/28
lo0/v6            static   ok           ::1/128


This setup do not not automatically reconnect to W0 upon reboot.
Would this be by design of the fixed network configuration? I do not yet know.
By contrast, the reactive network configuration, such as the Automatic NCP does.
After a reboot it suffices to reenter the dladm connect-wifi command as above.

By the way, before shutdown or reboot it's advisable to manually disconnect.
Not issuing dladm disconnect-wifi before shutdown causes it to take a long time.
  

Renaming network interfaces

Since OpenSolaris Crossbow project it's possible to rename network interfaces. This capability is also know as vanity names. This is of great help in organizing and documenting system configuration.

By default, the physical names will be abstracted to net0, net1, and so on...
The net prefix can be tweaked on svc:/network/datalink-management:default.
See the linkname-policy/phys-prefix SMF property.
See also dlmgmtd(1m).

In most cases it seems advantageous to rename interfaces.
For example, assume a desktop with both a wired and wireless connection.
By default, there will exist both net0 and net1.
But it could be easier to give them more meaningful names.
Assuming the wired interface is net0 it could be renamed to e0 (for ethernet).
By the same token I'd rather rename net1 to w0 (for wireless).
To accomplish this it suffices to:
 
# dladm rename-link net0 e0
# dladm rename-link net1 w0 


But note that you can only do this if the link is not busy.
Otherwise you get error messages such as:

# dladm rename-link net0 e0
dladm: rename operation failed: link busy    
     

Sunday, December 23, 2012

Network Configuration Profiles

Solaris 11.1 documentation has greatly improved on this area.
Network Configuraton Profiles (NCPs) types are now very clearly described:
 
  • Fixed
    There can exist only one per system.
    The system-generated one is called DefaultFixed.
    This NCP is generally used by the Text Installer.
      
  • Reactive
    There can exist as many as needed.
    The system-generated one is called Automatic.
    This NCP is generally used by the GUI Installer.

Of course it's paramount to know the implications of each NCP type.
After installation, netadm command can be used to select the active NCP type.
The reactive NCP type may be mostly interesting for non-server installations.
Nevertheless I believe certain server installations may profit from them as well.

To make the system use the default fixed NCP:

# netadm enable -p ncp DefaultFixed
# netadm list -p ncp 
TYPE        PROFILE        STATE
ncp         DefaultFixed   online
ncp         Automatic      disabled  

To make the system use the default reactive NCP:

# netadm enable -p ncp Automatic
# netadm list -p ncp 
TYPE        PROFILE        STATE
ncp         DefaultFixed   disabled
ncp         Automatic      online

NOTE
Under Solaris 11 Express things are quite different.
And after a live install, ipfilter may stay in the way.
(if so, one should find out more detail under /etc/nwam)

The automatic stuff is called Network Auto Magic (nwam).
The procedure to revert to a fixed configuration is as follows:

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


Then the manual configuration can be carried out as usual.