System Administration Guide: IP Services

ProcedureHow to Change the IPv4 Address and Other Network Configuration Parameters

This procedure explains how to modify the IPv4 address, host name, and other network parameters on a previously installed system. Use the procedure for modifying the IP address of a server or networked standalone system. The procedure does not apply to network clients or appliances. The steps create a configuration that persists across reboots.


Note –

The instructions apply specifically to changing the IPv4 address of the primary network interface. To add another interface to the system, refer to How to Configure a Physical Interface After System Installation.


In almost all cases, the following steps use traditional IPv4 dotted decimal notation to specify the IPv4 address and subnet mask. Alternatively, you can use CIDR notation to specify the IPv4 address in all the applicable files in this procedure. For an introduction to CIDR notation, see IPv4 Addresses in CIDR Format.

  1. Assume the Primary Administrator role, or become superuser.

    The Primary Administrator role includes the Primary Administrator profile. To create the role and assign the role to a user, see Chapter 2, Working With the Solaris Management Console (Tasks), in System Administration Guide: Basic Administration.

  2. For Solaris 10 11/06 and earlier releases only, modify the IP address in the /etc/inet/ipnodes file or equivalent ipnodes database.

    Use the following syntax for each IP address that you add to the system:


    IP-address host-name, nicknames
    IP-address interface-name, nicknames
    

    The first entry should contain the IP address of the primary network interface and the host name of the system. You can optionally add nicknames for the host name. When you add additional physical interfaces to a system, create entries in /etc/inet/ipnodes for the IP addresses and associated names of those interfaces.

  3. If the system's host name must change, modify the host name entry in the /etc/nodename file.

  4. Modify the IP address and, if applicable, the host name in the /etc/inet/hosts file or equivalent hosts database.

  5. Modify the IP address in the /etc/hostname.interface file for the primary network interface.

    You can use any of the following as the entry for the primary network interface in the /etc/hostnameinterface file:

    • IPv4 address, expressed in traditional dotted decimal format

      Use the following syntax:


      IPv4 address subnet mask
      

      The netmask entry is optional. If you do not specify it, the default netmask is assumed.

      Here is an example:


      # vi hostname.eri0
      10.0.2.5 netmask 255.0.0.0
      
    • IPv4 address, expressed in CIDR notation, if appropriate for your network configuration.


      IPv4 address/network prefix
      

      Here is an example:


      # vi hostname.eri0
      10.0.2.5/8
      

      The CIDR prefix designates the appropriate netmask for the IPv4 address. For example, the /8 above indicates the netmask 255.0.0.0.

    • Host name.

      To use the system's host name in the /etc/hostname.interface file, be sure that the host name and associated IPv4 address are also in the hosts database.

  6. If the subnet mask has changed, modify the subnet entries in the following files:

    • /etc/netmasks

    • (Optional) /etc/hostname.interface

  7. If the subnet address has changed, change the IP address of the default router in /etc/defaultrouter to that of the new subnet's default router.

  8. Reboot the system.


    # reboot -- -r
    

Example 5–1 Modifying the IPv4 Address and Other Network Parameters to Persist Across Reboots

This example shows how to change the following network parameters of a system that is moved to another subnet:

Check the system's current status:


# hostname
myhost
# ifconfig -a

lo0: flags=1000849 <UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000 
eri0: flags=1000843 <UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 10.0.0.14 netmask ff000000 broadcast 10.255.255.255
        ether 8:0:20:c1:8b:c3 

Next, change the system's host name and the IP address of eri0 in the appropriate files:


# vi /etc/nodename
mynewhostname

In Solaris 10 11/06 and earlier Solaris 10 releases only, do the following:
# vi /etc/inet/ipnodes
192.168.55.14   mynewhostname      #moved system to 192.168.55 net

# vi /etc/inet/hosts
#
# Internet host table
#
127.0.0.1       localhost
192.168.55.14   mynewhostname        loghost
# vi /etc/hostname.eri0
192.168.55.14   netmask  255.255.255.0

Finally, change the netmask and the IP address of the default router.


# vi /etc/netmasks.
.
.
192.168.55.0    255.255.255.0
# vi /etc/defaultrouter
192.168.55.200        #moved system to 192.168.55 net
#

After making these changes, reboot the system.


# reboot -- -r

Verify that the configuration you just set is maintained after the reboot:


# hostname
mynewhostname
# ifconfig -a

lo0: flags=1000849 <UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000 
eri0: flags=1000843 <UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 192.168.55.14 netmask ffffff00 broadcast 10.255.255.255
        ether 8:0:20:c1:8b:c3 


Example 5–2 Changing the IP Address and Host Name For the Current Session

This example shows how to change a host's name, IP address of the primary network interface, and subnet mask for the current session only. If you reboot, the system reverts to its previous IP address and subnet mask. The IP address for the primary network interface eri0 changes from 10.0.0.14 to 192.168.34.100.


# ifconfig -a

lo0: flags=1000849 <UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000 
eri0: flags=1000843 <UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 10.0.0.14 netmask ff000000 broadcast 10.255.255.255
        ether 8:0:20:c1:8b:c3 
# ifconfig eri0 192.168.34.100 netmask 255.255.255.0 broadcast + up
# vi /etc/nodename
mynewhostname

# ifconfig -a
lo0: flags=1000849 <UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000 
eri0: flags=1000843 <UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 192.168.34.100 netmask ffffff00 broadcast 10.255.255.255
        ether 8:0:20:c1:8b:c3 
# hostname
mynewhostname


Example 5–3 Changing the IPv4 Address for the Current Session, Using CIDR Notation

This example shows how to change a host name and IP address for the current session only, using CIDR notation. If you reboot, the system reverts to its previous IP address and subnet mask. The IP address for the primary network interface, eri0, changes from 10.0.0.14 to 192.168.6.25/27.


# ifconfig -a

lo0: flags=1000849 <UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000 
eri0: flags=1000843 <UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 10.0.0.14 netmask ff000000 broadcast 10.255.255.255
        ether 8:0:20:c1:8b:c3 
# ifconfig eri0 192.168.6.25/27 broadcast + up
# vi /etc/nodename
mynewhostname
# ifconfig -a

lo0: flags=1000849 <UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000 
eri0: flags=1000843 <UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 192.168.06.25 netmask ffffffe0 broadcast 10.255.255.255
        ether 8:0:20:c1:8b:c3 
# hostname
mynewhostname

When you use CIDR notation for the IPv4 address, you do not have to specify the netmask. ifconfig uses the network prefix designation to determine the netmask. For example, for the 192.168.6.0/27 network, ifconfig sets the netmask ffffffe0. If you had used the more common /24 prefix designation, the resulting netmask is ffffff00. Using the /24 prefix designation is the equivalent of specifying the netmask 255.255.255.0 to ifconfig when configuring a new IP address.


See Also

To change the IP address of an interface other than the primary network interface, refer to System Administration Guide: Basic Administration and How to Configure a Physical Interface After System Installation.