Network configuration in Oracle Solaris 11 works differently than in Oracle Solaris 10.
This tutorial provides basic information about how to configure your network in this
release.
Managing Network Configuration When in Manual Mode
Managing Network Configuration When in Automatic Mode
Managing Network Configuration When in Manual Mode
If you are manually configuring your network, keep the following key points in
mind:
To manually configure the network by using the dladm and ipadm commands, the DefaultFixed NCP must be active (online) after the installation or upgrade. Use the netadm command to verify which NCP is currently active on your system. See Example 7-1.
If the DefaultFixed NCP is not active, you will need to enable the profile before you can manually configure the network. See Example 7-2.
Persistent network configuration is now managed through SMF, not by editing the following files:
- /etc/defaultdomain
- /etc/dhcp.*
- /etc/hostname.*
- /etc/hostname.ip*.tun*
- /etc/nodename
- /etc/nsswitch.conf
Configuring Network Interfaces When in Manual Mode
The ipadm command is used to manually configure IP interfaces and addresses. For
example, a static IPv4 interface is configured as follows:
# ipadm create-ip net0 # ipadm create-addr -T static -a local=10.9.8.7/24 net0/addr
The -T option can be used to specify three address types: static,
dhcp, and addrconf (for auto-configured IPv6 addresses). In this example, the system is
configured with a static IPv4 address. Use the same syntax to specify a
static IPv6 address.
Configure an interface with DHCP as follows:
# ipadm create-ip net0 # ipadm create-addr -T dhcp net0/addr
Use the addrconf argument with the -T option to specify an automatically generated IPv6 address:
# ipadm create-ip net0 # ipadm create-addr -T addrconf net0/addr
If the net0 interface in this example was created, and you then wanted
to change the IP address that was provided for this interface, you would
need to first remove the interface and then re-add it:
# ipadm delete-ip net0 # ipadm create-ip net0 # ipadm create-addr -T addrconf net0/new-add
Displaying and Configuring Link Interfaces When in Manual Mode
Display information about the datalinks on a system as follows:
# dladm show-phys
LINK MEDIA STATE SPEED DUPLEX DEVICE
net2 Ethernet up 10000 full hxge0
net3 Ethernet up 10000 full hxge1
net4 Ethernet up 10 full usbecm0
net0 Ethernet up 1000 full igb0
net1 Ethernet up 1000 full igb1
net9 Ethernet unknown 0 half e1000g0
net5 Ethernet unknown 0 half e1000g1
net10 Ethernet unknown 0 half e1000g2
net11 Ethernet unknown 0 half e1000g3
Display a datalink name, its device name, and its location in this
manner:
# dladm show-phys -L net0
LINK DEVICE LOC
net0 e1000g0 IOBD
Rename a datalink as follows:If an IP interface is configured over the datalink, first remove that interface.
# ipadm delete-ip interface
Then, change the link's current name.
# dladm rename-link old-linkname new-linkname
Configuring Naming Services When in Manual Mode
The SMF repository is the primary repository for all naming services configuration. The previous behavior of modifying a configuration file to configure naming services no longer works. These services, for example, svc:/system/name-service/switch, svc:/network/dns/client, and svc:/system/name-service/cache must be enabled or refreshed for any changes to take affect.Example 7-3 Configuring Naming Services by Using SMF
The following example shows how to configure DNS by using SMF commands.
# svccfg
svc:> select dns/client
svc:/network/dns/client> setprop config/search = astring: \
("us.company.com" "eu.company.com" "companya.com" "companyb.com" "company.com" )
svc:/network/dns/client> setprop config/nameserver = net_address: \
( 138.2.202.15 138.2.202.25 )
svc:/network/dns/client> select dns/client:default
svc:/network/dns/client:default> refresh
svc:/network/dns/client:default> validate
svc:/network/dns/client:default> select name-service/switch
svc:/system/name-service/switch> setprop config/host = astring: "files dns"
svc:/system/name-service/switch> select system/name-service/switch:default
svc:/system/name-service/switch:default> refresh
svc:/system/name-service/switch:default> validate
svc:/system/name-service/switch:default>
# svcadm enable dns/client
# svcadm refresh name-service/switch
# grep host /etc/nsswitch.conf
hosts: files dns
# cat /etc/resolv.conf
#
# opyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
#
#
# _AUTOGENERATED_FROM_SMF_V1_
#
# WARNING: THIS FILE GENERATED FROM SMF DATA.
# DO NOT EDIT THIS FILE. EDITS WILL BE LOST.
# See resolv.conf(4) for details.
search us.company.com eu.company.com companya.com companyb.com company.com
nameserver 138.2.202.15
nameserver 138.2.202.25
.
.
.
Example 7-4 Setting Multiple NIS Servers by Using SMFThe following example shows how to set multiple NIS servers.
# svccfg -s nis/domain setprop config/ypservers = host: (1.2.3.4 5.6.7.8)
Example 7-5 Setting Multiple DNS Options by Using SMFThe following example shows how to set multiple /etc/resolv.conf options.
# svccg svc:> select /network/dns/client svc:/network/dns/client> setprop config/options = "ndots:2,retrans:3,retry:1" svc:/network/dns/client> listprop config/options config/options astring ndots:2,retrans:3,retry:1 # svcadm refresh dns/client # grep options /etc/resolv.conf options ndots:2,retrans:3,retry:1
Temporarily Resetting SMF Naming Services
Reset configuration properties of an SMF naming service back to a files only mode as follows:# /usr/sbin/nscfg unconfig name-service/switch
# svcadm refresh name-service/switch
Importing Network Configuration
The nscfg command transfers legacy file configuration for the name-service switch components into
the SMF repository. The command imports the legacy file, converting and pushing the
configuration to SMF. For example:
# /usr/sbin/nscfg import -f FMRI
In this example, the nscfg command reads information in the /etc/resolv.conf file, converts it, then stores the information in the svc:/network/dns/client SMF service.
# /usr/sbin/nscfg import -f dns/client
If your system is running in files only mode, and no naming services have been configured or enabled, use the nscfg command to manually configure the system, as shown here:
# vi /etc/resolv.conf # /usr/sbin/nscfg import -f dns/client # cp /etc/nsswitch.dns /etc/nsswitch.conf # /usr/sbin/nscfg import -f name-service/switch # svcadm enable dns/client # svcadm refresh name-service/switch
How to Use a Legacy nsswitch.conf File
When you change a system's naming service, you need to modify the name service switch information accordingly.- Become an administrator.
- Copy the nsswitch.conf file to the new system.
- Load the information from the file into the SMF repository.
# nscfg import -f svc:/system/name-service/switch:default
- Refresh the name service switch SMF service.
# svcadm refresh name-service/switch
Managing Network Configuration When in Automatic Mode
An NCP configures network links and interfaces. A Location configures system-wide network settings,
for example naming services and IPfilter settings. NCPs are made up of individual
configuration objects that are called Network Configuration Units (NCUs). Each NCU represents a
physical link or an interface that includes the properties that define the configuration
for that particular link or interface, as shown in the output of the
netcfg list command in the following example:
netcfg> select ncp myncp netcfg:ncp:myncp:ncu:nge0> list ncu:nge0 type interface class ip parent "myncp" enabled true ip-version ipv4,ipv6 ipv4-addrsrc dhcp ipv6-addrsrc dhcp,autoconf
User-defined NCPs and Locations are created by using the netcfg command, either in
command-line mode or interactively. For example, you would create a new NCP called
myncp by using the netcfg command interactively as follows:
$ netcfg netcfg> create ncp myncp
You can configure network settings for an NCP when you create it,
or you can configure or reconfigure network settings for an existing NCP by
using the nefcfg select command either in command-line mode or interactively, as shown in the
following example.
Example 7-6 Configuring a Static IP Address for an existing NCP
In the following example, the netcfg command is used interactively to select the
newly created NCP, myncp, then a static IP address is configured for this
NCP.
netcfg> select ncp myncp netcfg:ncp:myncp:ncu:nge0> list ncu:nge0 type interface class ip parent "myncp" enabled true ip-version ipv4,ipv6 ipv4-addrsrc dhcp ipv6-addrsrc dhcp,autoconf netcfg:ncp:myncp:ncu:nge0> set ipv4-addrsrc=static netcfg:ncp:myncp:ncu:nge0> set ipv4-addr=1.2.3.4/24 netcfg:ncp:myncp:ncu:nge0> set ipv4-default-route=1.2.3.1 netcfg:ncp:myncp:ncu:nge0> end Committed changes netcfg:ncp:myncp>
Example 7-7 Enabling an NCP
In the following example, a user-defined NCP named myncp is enabled by using the netadm command.
$netadm enable -p myncp Enabling ncp 'myncp' $
Configuring Naming Services When in Automatic Mode
System-wide network configuration, for example, naming services configuration, is managed in the Location
profile. Properties are configured by using the netcfg command. The Automatic Location
profile allows the system to automatically configure naming services. The Automatic Location profile is
used to configure DNS through DHCP only. Note that the Automatic Location is
different than the Automatic NCP, which configures link and IP interfaces.
Before configuring
naming service properties in a Location, you need to update the file that
is to be referenced by the nameservices-config-file property of the specified Location.
This file can be stored anywhere on the system. However, do not use
the /etc/nsswitch.conf file name, as this file is overwritten.
$ netcfg netcfg> create loc officeloc Created loc 'officeloc'. Walking properties ... activation-mode (manual) [manual|conditional-any|conditional-all]> conditional-all conditions> advertised-domain contains oracle.com nameservices (dns) [dns|files|nis|ldap]> nis nameservices-config-file ("/etc/nsswitch.dns")> /etc/nsswitch.nis nis-nameservice-configsrc [manual|dhcp]> dhcp nfsv4-domain> ipfilter-config-file> ipfilter-v6-config-file> ipnat-config-file> ippool-config-file> ike-config-file> ipsecpolicy-config-file> netcfg:loc:officeloc> end Committed changes netcfg>
In the following example NIS is configured for an existing location.
$ netcfg> select loc origloc netcfg:loc:origloc> set nameservices=dns,nis netcfg:loc:origloc> set nis-nameservice-configsrc=manual netcfg:loc:origloc> set nis-nameservice-servers="1.2.3.38.1.3.3.36" netcfg:loc:origloc> set default-domain="org.company.com" netcfg:loc:origloc> set nameservices-config-file="/etc/nsswitch.dns" netcfg:loc:origloc> end Committed changes netcfg> exit