Thursday, August 16, 2012

Using nwam to set a static ip on Open Indiana


Using Networking Automagic (NWAM) under Open Indiana is sweet.  It puts all those annoying Solaris network configuration elements into one sub-system, and then adds value by allowing us to have multiple network configurations and switch between them.

In NWAM parlance, an ncp is a Network Configuration Profile where you set the ip address, subnet etc and you can have as many of these as you like.  In order for DNS to work, you also have one or more locations (called a LOC) in which we set the search domain, dns servers etc and you can switch between them too.

When we needed to deploy a server for a remote office we simply created a ncp and a loc for that office, and switched to it just before turning the machine off.  This is how we did that.

First, determine the name of the network interface.  In this case nge0
$ ifconfig -a
lo0: flags=2001000849 mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
nge0: flags=1000843 mtu 1500 index 5
        inet 10.10.1.44 netmask ffffff00 broadcast 10.10.1.255
Then configure a ncp for your physical network , and also a loc for the dns settings;
$ sudo /usr/sbin/nwamcfg
nwamcfg> create ncp 132DaveySt
nwamcfg:ncp:132DaveySt> create ncu phys nge0
Created ncu 'nge0'.  Walking properties ...
activation-mode (manual) [manual|prioritized]> prioritized 
enabled (true) [true|false]>
priority-group> 0
priority-mode [exclusive|shared|all]> shared
link-mac-addr>
link-autopush>
link-mtu>
nwamcfg:ncp:132DaveySt:ncu:nge0> end
Committed changes
nwamcfg:ncp:132DaveySt> create ncu ip nge0
Created ncu 'nge0'.  Walking properties ...
enabled (true) [true|false]>
ip-version (ipv4,ipv6) [ipv4|ipv6]>
ipv4-addrsrc (dhcp) [dhcp|static]> static
ipv4-addr> 10.10.1.44/24
ipv4-default-route> 10.10.1.254
ipv6-addrsrc (dhcp,autoconf) [dhcp|autoconf|static]> dhcp,autoconf,static
ipv6-addr>
ipv6-default-route>
nwamcfg:ncp:132DaveySt:ncu:nge0> end
Committed changes
nwamcfg:ncp:132DaveySt> end
nwamcfg> list
NCPs:
132DaveySt
Automatic
Locations:
Automatic
NoNet
User
nwamcfg> create loc 132DaveySt
Created loc '132DaveySt'. Walking properties ...
activation-mode (manual) [manual|conditional-any|conditional-all]>
enabled (false) [true|false]> true
nameservices (dns) [dns|files|nis|ldap]> dns
nameservices-config-file ("/etc/nsswitch.dns")>
dns-nameservice-configsrc (dhcp) [manual|dhcp]> manual
dns-nameservice-domain> natoffice.wilderness.org.au
dns-nameservice-servers> 10.10.1.6
dns-nameservice-search> natoffice.wilderness.org.au
nfsv4-domain>
ipfilter-config-file>
ipfilter-v6-config-file>
ipnat-config-file>
ippool-config-file>
ike-config-file>
ipsecpolicy-config-file>
nwamcfg:loc:132DaveySt> end
Committed changes
nwamcfg> end
and then we enable the NCP and the LOC and we're good to go.
$ sudo /usr/sbin/nwamadm enable -p ncp 132DaveySt
$ sudo /usr/sbin/nwamadm enable -p loc 132DaveySt

No comments: