Knowledgebase: Operating System > Solaris
Configuring IPv4 Interfaces
Posted by Sandi Widianto on 17 November 2022 01:46 PM

Configuring IP interfaces enables a system to connect to the network. The procedure essentially involves assigning IP addresses to the interfaces.

When you assign an IP address to an IP interface, a corresponding address object is created to represent that address.

The address object uses the format interface/address-family, where address-family is either v4 or v6. For example, net0 with an IPv4 address would have the address object net0/v4. Multiple address objects of the same IP interface are distinguished by a letter suffix, such as net0/v4a, net0/v4b, net0/v4c, and so on.

Similarly, an IP interface with IPv6 addresses would have address objects such as net1/v6a, net1/v6b, and so on.

Any subsequent command on this interface's address can use the address object as reference. For instance, using an address object from the previous examples, you would type ipadm delete-addr net0/v4b.

How to Configure an IPv4 Interface

Before You Begin

Ensure that your role has the appropriate rights profile to perform this procedure. See Using Rights Profiles to Perform Network Configuration.

  1. Create the IP interface.
    $ ipadm create-ip interface

    The interface name follows the datalink name on which the interface is created.

    This syntax is the most commonly used to configure networking on a system. However, two other create subcommands are available for other types of configuration:

  2. Configure the IP interface with a valid IP address.

    Use one of the following commands depending on the type of address:

    • Create a static address
      $ ipadm create-addr -a IP-address interface

      The address can be in Classless Inter-Domain Routing (CIDR) notation.

    • Configure a dynamic address.
      $ ipadm create-addr -T dhcp interface
  3. Display information about the system's IP interfaces.
    $ ipadm

    See also Monitoring IP Interfaces and Addresses that show how to obtain interface information by using show-* subcommands.

  4. 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 -  DHCP configurations do not require updates to the /etc/hosts file.

Example 2  Configuring an IPv4 Interface With a Static IP Address

The following example shows how to configure an IPv4 interface with a static IP address. The example also shows how to configure a persistent route for the interface by using the route command.

$ 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.0.2.3/24 net3
net3/v4

$ ipadm
NAME              CLASS/TYPE STATE        UNDER      ADDR
aggr0             ip         down         --         --
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.0.2.3/24

$ vi /etc/hosts
# Internet host table
# 127.0.0.1     localhost
203.0.113.14    foohost
192.0.2.3       sales1

Example 3  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 not include a step for manually adding a default route by using the route command.

$ 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
aggr0             ip         down         --         --
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           --         203.0.113.3/24
(0 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments: