Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › Static IP on Solaris 11/ Openindiana text installation
New Posts  All Forums:Forum Nav:

Static IP on Solaris 11/ Openindiana text installation

post #1 of 2
Thread Starter 
I've ran mostly desktop versions of OpenIndiana due the convoluted and broken documentation for actually setting a static IP strictly via console. I've taken a few tries at setting it up in the past and took the path of least resistance. Now I am needing to run a slimdown version of OpenIndiana (aka console only) and have been trying out a few diffrent guides. I need this to stay persistent over a reboot. I figured I would ask here as I know we have a few Solaris guru's!
post #2 of 2
Thread Starter 
For anyone that happend's to stumble upon this looking for same anwser the proper way it seems now is to use nwamcfg.

http://wiki.openindiana.org/oi/Using+NWAM+to+configure+network+interfaces
Quote:
Introduction
Network Auto-Magic (NWAM) is a new approach to managing network interfaces that was introduced with OpenSolaris. NWAM introduced network profiles to be able to change network settings on the fly and also a harmonized approach to service discovery (MDNS) configuration. One important reason to redesign networking was the increasing importance of wireless networking and the need to cope with its dynamic nature.

NWAM generally feels unfamiliar to long time users and thus is one of the features of OI generally underestimated and disabled as quickly as possible. On the other hand configuring network settings becomes quite easy using its main tools nwamcfg and nwamadm as this topic shows

Toolset
Generally, all configuration can be done using two tools, nwamcfg to configure network profiles and nwamadm to manage network profiles. On its backend, NWAM relies on nwamd, the NWAM policy engine daemon and netcfgd, its NWAM repository daemon. Additionally, all configuration can be done via a GUI application.

NWAM access control
Todo: Describe how profiles can be used to control access to NWAM.

Access to the command line and GUI tools is controlled via security profiles "Network Autoconf Admin" and "Network Autoconf user", respectively. All NWAM profile handling can be done as root, though.

Setting up a profile
First step usually is to create a new profile to populate. As root user, issue the following command:

# nwamcfg
nwamcfg> create ncp Abroad
nwamcfg:ncp:Abroad> exit
#
Now, next time you start nwamcfg, you will see a new profile in the list of NCPs:

# nwamcfg
nwamcfg> list
NCPs:
Abroad
Automatic
Locations:
Automatic
NoNet
User
nwamcfg>
Based on this, the network interface to be managed under the new profile can be set and configured:
# nwamcfg
nwamcfg> select ncp Abroad
nwamcfg:ncp:Abroad>
create ncu phys e1000g0
Created ncu 'e1000g0'. Walking properties ...
activation-mode (manual) [manual|prioritized]>
enabled (true) [true|false]>
priority-group> 0
priority-mode [exclusive|shared|all]> exclusive
link-mac-addr>
link-autopush>
link-mtu>
nwamcfg:ncp:Abroad:ncu:e1000g0>

Most important here is the activation-mode, which states if the profile is to be automatically set based on certain policies or if it is to be manually set using nwamadm. The latter should be most likely the case in a server environment. For the priority-group and -mode, the settings here (0 / exclusive) say that the profile is for wired access and will always be the only active one at a time.
If after listing the changes you are satisfied with the configuration, permanently store them using a commit:

nwamcfg:ncp:Abroad:ncu:e1000g0> list
ncu:e1000g0
type link
class phys
parent "Abroad"
activation-mode prioritized
enabled true
priority-group 0
priority-mode exclusive
nwamcfg:ncp:Abroad:ncu:e1000g0> commit
Committed changes
nwamcfg:ncp:Abroad:ncu:e1000g0>
Now that an interface has been assigned to the profile, its IP configuration has to be defined:

nwamcfg:ncp:Abroad:ncu:e1000g0> end
nwamcfg:ncp:Abroad> create ncu ip e1000g0
Created ncu 'e1000g0'. Walking properties ...
enabled (true) [true|false]>
ip-version (ipv4,ipv6) [ipv4|ipv6]> ipv4
ipv4-addrsrc (dhcp) [dhcp|static]> static
ipv4-addr> 192.168.100.100
ipv4-default-route> 192.168.100.1
nwamcfg:ncp:Abroad:ncu:e1000g0> list
ncu:e1000g0
type interface
class ip
parent "Abroad"
enabled true
ip-version ipv4
ipv4-addrsrc static
ipv4-addr "192.168.100.100"
ipv4-default-route "192.168.100.1"
ipv6-addrsrc dhcp,autoconf
nwamcfg:ncp:Abroad:ncu:e1000g0>
As you can see, the profile features a static IP address and, for simplicity reasons, only provides IPv4 networking. Again, if you're happy with the results, commit them.

nwamcfg:ncp:Abroad:ncu:e1000g0> commit
Committed changes
nwamcfg:ncp:Abroad:ncu:e1000g0>
As it stands, you now have defined a pysical and ip layer attached to a network profile:

nwamcfg:ncp:Abroad:ncu:e1000g0> end
nwamcfg:ncp:Abroad> list
NCUs:
phys e1000g0
ip e1000g0
nwamcfg:ncp:Abroad>exit
#
Activating a profile
To activate the profile, you use nwamadm. First of all, check for the current situation:

# nwamadm list
TYPE PROFILE STATE
ncp Abroad disabled
ncp Automatic online
ncu:phys e1000g0 online
ncu:ip e1000g0 online
loc Automatic online
loc NoNet offline
loc User disabled
#
As you can see, Automatic is the active profile while Abroad is currently disabled. We can change that easily, but be aware that you might lock yourself out if you are connected via SSH when changing the profile!

# nwamadm enable Abroad
Enabling ncp 'Abroad'
To check if the change has worked, you can use nwam again, and also ifconfig should show success:

# nwamadm list
TYPE PROFILE STATE
ncp Abroad online
ncu:phys e1000g0 online
ncu:ip e1000g0 online
ncp Automatic disabled
loc Automatic online
loc NoNet offline
loc User disabled

# ifconfig e1000g0
e1000g0: flags=1000843 mtu 1500 index 8
inet 192.168.100.100 netmask ffffff00 broadcast 192.168.100.255
ether 0:c:29:56:46:73
#

Scripting
Although it is possible to directly modify profiles using an editor, it is not advisable and will be hardly necessary, anyway. One of the coolest features of NWAM tools is that they can be completely scripted. All steps above could also be put into two lines only:

# nwamcfg "create ncp Abroad;create ncu phys e1000g0;set activation-mode=manual;set enabled=true;set priority-group=0;set priority-mode=exclusive;end;create ncu ip e1000g0;set enabled=true;set ip-version=ipv4;set ipv4-addrsrc=static;set ipv4-addr=192.168.100.100;set ipv4-default-route=192.168.100.1;commit"
#

Or, more nicely formatted, commented and stored in a file:

#
# Profile for use on the road
#
# Created on 13/01/2013 by S. Mueller-Wilken
#
create ncp Abroad
# Create physical interface definition for 1st network card
create ncu phys e1000g0
set activation-mode=manual
set enabled=true
set priority-group=0
set priority-mode=exclusive
end
# Create IP configuration for first network card
create ncu ip e1000g0
set enabled=true
set ip-version=ipv4
set ipv4-addrsrc=static
set ipv4-addr=192.168.100.100
set ipv4-default-route=192.168.100.1
# Commit the settings
commit
This file can then be read by nwamcfg, directly or, e.g. as part of a zone configuration, using zlogin:

# nwamcfg -f abroad.cfg
Configuration read.
#
Behind the scenes
While there is no longer a need to fiddle around in /etc/nwam, the configuration is still completely there, as can be easily verified:

# ls /etc/nwam
loc loc.conf ncp-Abroad.conf ncp-Automatic.conf
#
All configuration is placed in readable ASCII files so that configuration from a global zone is possible:

# cat /etc/nwam/ncp-Abroad.conf
link:e1000g0 type=uint64,0;class=uint64,0;parent=string,Abroad;enabled=boolean,true;activation-mode=uint64,4;priority-group=uint64,0;priority-mode=uint64,0;
interface:e1000g0 type=uint64,1;class=uint64,1;parent=string,Abroad;enabled=boolean,true;ipv6-addrsrc=uint64,0,1;ip-version=uint64,4;ipv4-addrsrc=uint64,2;ipv4-default-route=string,192.168.100.1;ipv4-addr=string,192.168.100.100;
#
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Linux, Unix
Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › Static IP on Solaris 11/ Openindiana text installation