Configuring automatically multiple NICs at installation time with Solaris 11.2

Solaris 11.2 comes with several new and major features such as the Unified Archives, Open Stack integration and kernel zones to name a few. Alongside those major features many smaller but none the less useful enhancements are also introduced. One particular enhancement that has made my life easier is the possibility to automatically configure multiple NICs (network interface cards) at installation time.

After installing Solaris 11, on bare metal or in a Zone, the system needs to be configured at first boot. By default this process is manual: a system configuration wizard walks the user through different steps in order to gather such system parameters as the host name, IP address, net mask, time zone, root passwords and so on. Of course there exists a mechanism to make this process hands-off and fully part of the installation process. In order to do so a system configuration profile XML file needs to be provided at installation time, containing all the information needed to configure automatically the system. However so far, Solaris 11 only allowed the automatic configuration of a single NIC. On systems with several NICs, it was still necessary to configure all the remaining network interfaces, either manually, or by setting up a first boot script mechanism to perform this extra task.

In Solaris 11.2 this extra step becomes history: it is now possible to specify multiple NICs in the system configuration profile XML file in order get all NICs configured automatically during installation time. So how does it work? The best way demonstrating this would be to go through an example by installing a Solaris 11 Zone with two NICs and configuring them automatically. The first step is to create a simple Solaris 11 Zone with two NICs following Listing 1.

# zonecfg -z zone1
zonecfg:zone1> create –b
zonecfg:zone1> set zonepath=/zones/zone1
zonecfg:zone1> add anet
zonecfg:zone1:anet> set linkname=net0
zonecfg:zone1:anet> set lower-link=auto
zonecfg:zone1:anet> end
zonecfg:zone1> add anet
zonecfg:zone1:anet> set linkname=net1
zonecfg:zone1:anet> set lower-link=auto
zonecfg:zone1:anet> end
zonecfg:zone1> verify
zonecfg:zone1> commit
zonecfg:zone1> exit

Listing 1


At this point the Zone is configured but not yet installed as confirmed by the following command

# zoneadm list –civ
ID NAME             STATUS      PATH                         BRAND      IP    
 0 global           running     /                            solaris    shared
 - zone1            configured  /zones/zone1                 solaris    excl

Before actually installing the Zone “zone1”, a system configuration XML file should be created in order to configure automatically the Zone.
As an example Listing 2 provides a system configuration file called sc_profile.xml used to configure the Zone’s two NICs: net0 and net 1 will be respectively assigned the IP addresses 10.0.2.101/24 and 192.168.1.34/24. (The part of the file concerning network configuration is in bold)

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type="profile" name="sysconfig">
  <service version="1" type="service" name="system/identity">
    <instance enabled="true" name="node">
      <property_group type="application" name="config">
        <propval type="astring" name="nodename" value="zone1"/>
      </property_group>
    </instance>
  </service>
<service version="1" type="service" name="network/install">
    <instance enabled="true" name="default">

       <property_group type="ipv4_interface" name="ipv4_interface_0">
        <propval type="net_address_v4" name="static_address" value="10.0.2.101/24"/>
         <propval type="astring" name="name" value="net0/v4"/>
         <propval type="astring" name="address_type" value="static"/>
         <propval type="net_address_v4" name="default_route" value="10.0.2.2"/>
       </property_group>
       <property_group type="ipv4_interface" name="ipv4_interface_1">
         <propval type="net_address_v4" name="static_address" value="192.168.1.34/24"/>
         <propval type="astring" name="name" value="net1/v4"/>
         <propval type="astring" name="address_type" value="static"/>
         <propval type="net_address_v4" name="default_route" value="192.168.1.1"/>
       </property_group>

</instance>
   </service>

  <service version="1" type="service" name="network/physical">
    <instance enabled="true" name="default">
      <property_group type="application" name="netcfg">
        <propval type="astring" name="active_ncp" value="DefaultFixed"/>
      </property_group>
    </instance>
  </service>
  <service version="1" type="service" name="system/name-service/switch">
    <property_group type="application" name="config">
      <propval type="astring" name="default" value="files"/>
    </property_group>
    <instance enabled="true" name="default"/>
  </service>
  <service version="1" type="service" name="system/name-service/cache">
    <instance enabled="true" name="default"/>
  </service>
  <service version="1" type="service" name="system/environment">
    <instance enabled="true" name="init">
      <property_group type="application" name="environment">
        <propval type="astring" name="LANG" value="en_US.UTF-8"/>
      </property_group>
    </instance>
  </service>
</service_bundle>

Listing 2

For those already familiar with the system configuration files of Solaris 11 prior to Solaris 11.2, the only differences are the property group name which is now user-defined in order to allow multiple entries, and the property group type which changes from "application" to "ipv4-interface". However the older syntax is still valid as long as a single NIC is to be configured at installation time the existing system configuration files are relevant.

Now that all the pieces are ready, let’s proceed and actually install the Zone “zone1” by explicitly providing the system configuration file shown in Listing 2.

# zoneadm -z zone1 install -c /root/sc_profile.xml

Boot the Zone :
# zoneadm -z zone1 boot

Check that the zone is running:

# zoneadm list –civ
ID NAME             STATUS      PATH                         BRAND      IP    
 0 global           running     /                            solaris    shared
 3 zone1            running     /zones/zone1                 solaris    excl

Finally log into the Zone and verify the IP interfaces and addresses as well as the routing table:

# zlogin zone1
[Connected to zone 'zone1' pts/3]
Oracle Corporation    SunOS 5.11    11.2    June 2014

root@zone1:~# ipadm show-addr

ADDROBJ           TYPE     STATE        ADDR
lo0/v4            static   ok           127.0.0.1/8
net0/v4           static   ok           10.0.2.101/24
net1/v4           static   ok           192.168.1.34/24
lo0/v6            static   ok           ::1/128

root@zone1:~# netstat –rn

Routing Table: IPv4
  Destination           Gateway           Flags  Ref     Use     Interface
-------------------- -------------------- ----- ----- ---------- ---------
default              192.168.1.1          UG        1          0           
default              10.0.2.2             UG        1          0           
10.0.2.0             10.0.2.101           U         2          0 net0      
127.0.0.1            127.0.0.1            UH        2          0 lo0       
192.168.1.0          192.168.1.34         U         2          0 net1

As expected both NICs have been correctly configured and the defaults routes for each network added to the routing table.

EDIT:
As pointed out by a reader for more details you will find the documentation here:

http://docs.oracle.com/cd/E36784_01/html/E36800/gklew.html#scrolltoc

Comments:

Certainly this is of great help!

I would just add the documentation link for further detail:
http://docs.oracle.com/cd/E36784_01/html/E36800/gklew.html#scrolltoc

Thanks and regards.

Posted by Carlos Azevedo on August 15, 2014 at 02:23 PM CEST #

Hi Carlos

Thanks a lot for the comment: It certainly helps to add the link to the full documentation. As you will see I updated my post accordingly.

Thanks again for the feedback.

Cheers,
Amir

Posted by Amir Javanshir on August 20, 2014 at 06:23 PM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

How open innovation and technology adoption translates to business value, with stories from our developer support work at Oracle's ISV Engineering.

Subscribe

Search

Categories
Archives
« July 2015
SunMonTueWedThuFriSat
   
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
       
Today
Feeds