Skip to end of metadata
Go to start of metadata

Introduction

OpenIndiana 151a is by default installed to use NWAM and DHCP dynamic IPs. In many situations it would be preferred to set up a static IP for the server, something which is difficult to do through nwam.  There a few guides to use NWAM for Static IPs (examples: A, B, or C) but none seem straight forward.

GUI Way (easiest)

Using su, sudo or pfexec to acquire the required privileges:

Commands

Warning! This commands will first disable your network interface , if you are doing this,
you better be on the console and not on remote (ssh) connection or you will be locked out of machine. 

Use scripted commands in line,that bring interface Up right after bringing it down
or stay with NWAM untill you get local console access.

# svcadm disable svc:/network/physical:nwam

# svcadm enable svc:/network/physical:default
# cp /etc/nsswitch.dns /etc/nsswitch.conf
# network-admin

network-admin

Connections

General

DNS

Hosts

This last command will open a window in gnome in which you can fill in the required values.

Console Way

Commands (Solaris 11 and OpenIndiana 151):

# ipadm create-addr -T static -a 1.2.3.4/24 e1000g0/v4static
# route -p add default 1.2.3.254
# cp /etc/nsswitch.dns /etc/nsswitch.conf

# vi /etc/hosts
# vi /etc/resolv.conf

Commands:

# svcadm disable svc:/network/physical:nwam
# svcadm enable svc:/network/physical:default
# cp /etc/nsswitch.dns /etc/nsswitch.conf
# vi /etc/hosts
# vi /etc/resolv.conf
# vi /etc/defaultrouter
# vi /etc/hostname.NIC
# svcadm restart svc:/network/physical:default

files

The following files need to be edited.  Change the parts necessary, where oibox is the current computer name, example.net is the domain name (or workgroup). 

/etc/hosts
/etc/resolv.conf
/etc/defaultrouter

Note the file /etc/hostname._NIC_ will be something like /etc/hostname.bnx0 where the suffix is your physical NIC.

/etc/hostname.NIC

Potential Issues and Workarounds

Typically it is always a good ideas do all this work in a true console (direct keyboard plus screen or a BMC/iLOM/IMM device) as you may lose all networked connectivity to your system.

firewalls

 

The use of ipfilter (a firewall) can prevent the changes above from working.  To check if ipfilter is active

# svcs ipfilter

The following command to disable ipfilter may solve issues in trying to get a static IP to work.

# svcadm disable ipfilter 

alternate set of files changes 

A more traditional set of changes (similar to what sys-unconfig would do), allowing the system to have multiple IP addresses with different hostnames on each of your physical interfaces.  The below assumes you want the server to have Static IP: 192.168.1.16, hostname: oibox, a default route of 192.168.1.1, and to use google's DNS name servers of 8.8.8.8 and 8.8.4.4.   This is what I do, it is different than the above "files" section, and is based on information at http://www.outside-the-box.com/?p=185

/etc/hosts
/etc/resolv.conf
/etc/defaultrouter

Note the file /etc/hostname._NIC_ will be something like /etc/hostname.bnx0 where the suffix bnx0, pcn0, nge0, etc. is your physical NIC identifier.

/etc/hostname.NIC

ssh keys

You may wish to generate a new set of ssh keys to do this you will need to remove the keys, the will be regenerated automatically on next system reboot.

# rm  /etc/ssh/*key*

Other

This section needs to be merged with http://wiki.openindiana.org/oi/4.2+Network+management 

 
Labels:
  1. May 09, 2012

    Hi,

    ii think that /etc/hosts is symbolic link to /etc/inet/hosts since long time ago...

    Regards.

    1. May 09, 2012

      Yes, but "/etc/hosts" is the name by which many Unix admins know such a resource. It is indeed a symlink in Solaris 8 already, I don't have any older systems running to look at now (wink)

      Also note that there is a similar file "/etc/inet/ipnodes" (which since approximately Solaris 10u4 is a symlink to "./hosts") with the same format and function. In the times when these files were different (and that can still be done manually today) their difference could cause some hair-pulling when local or remote systems were renamed or re-addressed in DNS and /etc/hosts, yet old names or addresses kept coming up in practice. One particular example was disabling of IPv6 "::1" localhost address in one and not the other.

      Yet the separation of two files allowed to configure "overriding" names and "backup" names of the remote hosts by configuring nsswitch to "files dns" for one database and "dns files" for another. For example, you might want to look up the LDAP server according to its DNS name, but if that is not available - try to use the "hardcoded" and possibly obsolete name/address from the file.

      HTH,
      //Jim Klimov

  2. May 09, 2012

    Using dladm and ipadm seems to work fine lately, any reason not to use them for the example. (the note concerning ipfilter is definitely a valid one that can bite when not looking).

    Also, is there any particular reason to want (or need) to generate a new set of ssh keys?

  3. Aug 06, 2013

    It's obsolete way for oi_151a7.

    This guide works fine until reboot.

    After reboot system loses ipadm's settings and almost all services are offline, cause physical:default is in maintenance state - it's startup script can't configure interfaces :(

    If you login locally and manually enter ipadm create-addr -T static -a local=... interface/suffix the physical:default should start after clean command.

    On a result the best way is to use nwamcfg and nwamadm for simple static IP-address configuration.

    But new trap is waiting for you if you have a non-global zone(s).