Configuring and Administering Network Components in Oracle® Solaris 11.2

Exit Print View

Updated: September 2014
 
 

How to Configure an IPv4 Interface

Before You Begin

Check which NCP is active on the system to make sure that you are applying the configuration to the correct profile. See Example 6–6.

  1. Become an administrator.
  2. Create the interface.
    # ipadm create-interface-class interface
    interface-class

    Refers to one of three classes of interfaces that you can create:

    • IP interface

      This interface class is the most common class that you create when performing network configuration. To create this interface class, use the create-ip subcommand.

    • STREAMS virtual network interface (VNI interface)

      To create this interface class, use the create-vni subcommand.

      Starting with Oracle Solaris 11.2, you can name VNI interfaces more arbitrarily. Previously, a VNI interface name must have included "vni" in its prefix, for example vni0. This requirement no longer applies. For more information about VNI devices and interfaces, see the vni (7d) and ipadm (1M) man pages.

    • IPMP interface

      This interface class is used when you configure IPMP groups. To create this interface class, use the create-ipmp subcommand. For more information about IPMP groups, see Chapter 2, About IPMP Administration, in Administering TCP/IP Networks, IPMP, and IP Tunnels in Oracle Solaris 11.2 .

    interface

    Refers to the name of the interface. The name is identical to the name of the datalink over which the interface is being created. To display the datalinks that are on a system, use the dladm show-link command.

  3. Configure the IP interface with a valid IP address by using one of the following commands:
    • Configure a static IP address:

      # ipadm create-addr -a address [interface | addrobj]
      –a address

      Specifies the IP address to configure on the interface.


      Note -  Tunnel configuration typically requires two addresses for the tunnel interface: a local address and a remote address. For information about local and remote addresses and tunnel configuration, see Chapter 5, Administering IP Tunnels, in Administering TCP/IP Networks, IPMP, and IP Tunnels in Oracle Solaris 11.2 .

      For numeric IP addresses, use Classless Inter-Domain Routing (CIDR) notation. If you do not use CIDR notation, the netmask is determined by using the svc:/system/name-service/switch:default netmask database search order or by using classful address semantics.

      Optionally, you can specify a host name instead of a numeric IP address. Using a host name is valid if a corresponding numeric IP address is defined for that host name in the /etc/hosts file. If no numeric IP address is defined in the file, then the numeric value is uniquely obtained by using the resolver order that is specified for host in the name-service/switch service. If multiple entries exist for a given host name, an error is generated.


      Note -  During the boot process, IP addresses are configured prior to naming services being brought online. Therefore, you must ensure that any host name that is used in the network configuration is defined in the /etc/hosts file.
      [interface | addrobj]

      In Oracle Solaris, each address is identified by a corresponding address object and represented in the command by addrobj. For any subsequent configuration on the address, you would refer to the address object instead of the actual IP address. For example, you would type ipadm show-addr addrobj or ipadm delete-addr addrobj. To have the address object name generated automatically, specify only the interface name for interface. To manually name the address object, provide the address object name directly.

      • If you specify the interface name, then an address object is automatically named with the format interface/address-family. Address family is either v4 for an IPv4 address or v6 for an IPv6 address. If multiple addresses are configured on an interface by using automatically generated address object names, then alphabetic letters are appended to the address object names so that they are unique. For example, net0/v4, net0/v4a, net0/v4b, net0/v6, net0/v6a, and so on.

      • If you manually name the address object for addrobj, you must use the format interface/user-specified-string. User-specified-string refers to a string of alphanumeric characters that begins with an alphabetic letter and has a maximum length of 32 characters. For example, you can name address objects net0/static, net0/static1, net1/private, and so on.

    • Configure a non-static address.

      # ipadm create-addr -T address-type [interface | addrobj]

      where address-type is either dhcp or addrconf. The addrconf argument refers to automatically generated IPv6 addresses.

      For a more detailed explanation of the interface and addrobj options, refer to the previous description for creating static addresses.

  4. (Optional) Display information about the newly configured IP interface.

    You can use the following commands, depending on the information that you want to check:

    # ipadm interface

    If you do not specify a subcommand, information for all of the interfaces on the system is displayed.

    # ipadm show-if interface

    If you do not specify an interface, information for all of the interfaces on the system is displayed.

    # ipadm show-addr interface|addrobj

    If you do not specify an interface or addrobj, information for all of the address objects is displayed.

    For more information about the output of the ipadm show-* subcommand, see Monitoring IP Interfaces and Addresses.

  5. If you are configuring a static IP address that uses a host name, add the entries for the IP address to the /etc/hosts file.

    The entries in this file consist of IP addresses and their corresponding host names.


    Note -  If you are configuring a DHCP address, you do not need to update the /etc/hosts file.
  6. Define the default route.
    # route -p add default address

    You can verify the contents of the routing table with the netstat –r command.

    For more information about managing routes, see the route (1M) and Creating Persistent (Static) Routes.

Example 3-1  Configuring an IPv4 Interface With a Static IP Address

The following example shows how to configure an interface with a static IP address. The example begins with enabling the DefaultFixed NCP on the system to ensure that the dladm and ipadm commands do not modify a reactive NCP, which could negate any manual network configuration that you perform, depending on your environment.

# netadm enable -p ncp DefaultFixed

# dladm show-phys
LINK     MEDIA        STATE     SPEED     DUPLEX     DEVICE
net3     Ethernet     up        100Mb     full       bge3

# dladm show-link
LINK     CLASS     MTU     STATE     OVER
net3     phys      1500    up        --       --

# ipadm create-ip net3
# ipadm create-addr -a 192.168.84.3/24 net3
net3/v4

# ipadm
NAME      CLASS/TYPE     STATE     UNDER     ADDR
lo0       loopback       ok        --        --
lo0/v4     static        ok        --     127.0.0.1/8
lo0/v6     static        ok        --     ::1/128 
net3      ip             ok        --        --
net3/v4   static         ok        --     192.168.84.3/24

# vi /etc/hosts
# Internet host table
# 127.0.0.1     localhost
10.0.0.14       myhost
192.168.84.3    sales1

# route -p add default 192.168.84.1
# netstat -r
Routing Table: IPv4
Destination          Gateway              Flags Ref   Use        Interface
-------------------- -------------------- ----- ----- ---------- ---------
default              192.168.84.1         UG    2     10466
192.168.84.0         192.168.84.3         U     3     1810       net0
localhost            localhost            UH    2     12         lo0

Routing Table: IPv6
Destination/Mask            Gateway                 Flags Ref   Use    If
--------------------------- ------------------------- ----- --- ------- -----
solaris                       solaris                 UH      2     156  lo0

If sales1 is already defined in the /etc/hosts file, you can use that host name when assigning the following address:

# ipadm create-addr -a sales1 net3
net3/v4
Example 3-2  Configuring a Network Interface To Receive an IP Address From a DHCP Server

In the following example, the IP interface is configured to receive its address from a DHCP server. DHCP typically also installs a default route. Therefore, this example does include a step for manually adding a default route.

# dladm show-phys
LINK     MEDIA        STATE     SPEED     DUPLEX     DEVICE
net3     Ethernet     up        100Mb     full       bge3

# dladm show-link
LINK     CLASS     MTU     STATE     OVER
net3     phys      1500    up        --       --

# ipadm create-ip net3
# ipadm create-addr -T dhcp net3
net3v4

# ipadm
NAME      CLASS/TYPE     STATE     UNDER     ADDR
lo0       loopback       ok        --        --
l0/v4     static         ok        --        127.0.0.1/8
net3      ip             ok        --        --
net3/v4   dhcp           ok        --        10.0.1.13/24