The following procedure and examples describe how to configure a network that uses IPv4 addresses.
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 22, Switching Between the Fixed and Reactive Modes.
# ipadm create-interface-class interface
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
To create this interface class, use the create-vni subcommand.
You can name virtual network interfaces more arbitrarily. For more information about virtual network 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.3.
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.
Configure a static IP address:
# ipadm create-addr -a address [interface | addrobj]
Specifies the IP address to configure on the interface.
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.
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.
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.
The entries in this file consist of IP addresses and their corresponding host names.
# 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.
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.0.2.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.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 # route -p add default 192.0.2.1 # netstat -r Routing Table: IPv4 Destination Gateway Flags Ref Use Interface -------------------- ----------------- ----- ----- ---------- --------- default 192.0.2.1 UG 2 10466 192.0.2.0 192.0.2.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/v4Example 4 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. Note that this example includes a step for restarting the svc:/network/service:default SMF service, which updates the dns/client (resolv.conf) and name-service/switch (nsswitch.conf). services.
# 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 # svcadm restart network/service # 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/24Example 5 Configuring a Virtual Network Interface for Use With ILB
In previous releases, a virtual network interface name had to include vni in its prefix, for example vni0. However, this requirement no longer applies. You can now name virtual network interfaces more arbitrarily, as shown in the following example where an IPv4 virtual network interface (vip0/v4) is configured.
# ipadm create-vni vip0 # ipadm create-addr -T static -a 192.0.2.200/32 vip0/v4
Running the previous command enables the IP stack to accept packets that are destined for 192.0.2.200. You would use the same steps to set up a Virtual IP (VIP) address for an Integrated Load Balancer (ILB) back-end server when the Direct Server Return (DSR) mode is being used.
For more information about administering ILB, see Chapter 6, Configuring and Managing the Integrated Load Balancer in Configuring an Oracle Solaris 11.3 System as a Router or a Load Balancer.