Thursday, October 21, 2010

IP Address configuration for Sun Solaris 10


Just to share the experience, for this time is a little bit different. I’m going to share how to manage ip address configuration on Server Sun Solaris 10, either for fresh installation Solaris or just change old ip address configuration to a new one. Basically command shell in Sun Solaris look alike operating system unix base, but it slightly different with Linux Further more discuss on next line.

First we must know how syntax in network command on unix environment, such as ifconfig, netstat, ping and traceroute. Usually when run on solaris installation process on the first time, installation procedure always begin with network installation and all derivative process, until the procedure finish with no error result, when we in solaris shell console and type ifconfig or netstat command will show result like show below on display:

# ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
nge0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet xx.xx.x.x netmask ffff0000 broadcast xx.xx.xxx.xxx
ether 0:21:28:25:6b:c4
nge1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3
inet xxx.xxx.xxx.xxx netmask fffffff8 broadcast xxx.xxx.xxx.xxx
ether 0:21:28:25:6b:c5
#

Notice the sample script above, from three interface shown above we can see the status is UP and looked in this script “<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL>” and “<UP,BROADCAST,RUNNING,MULTICAST,IPv4>” which mean this configuration is correct and working properly, also we can looked at sample script like shown below. Figure below is show how the route between pc to gateway and to intranet or internet.

# netstat -rn

Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
-------------------- -------------------- ----- ----- ------ ---------
xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx U 1 700 nge1
xx.xx.x.x xx.xx.x.x U 1 64128 nge0
224.0.0.0 xxx.xxx.xxx.xxx U 1 0 nge1
default xxx.xxx.xxx.xxx UG 11495783
127.0.0.1 127.0.0.1 UH 235 829415 lo0
#

If in shell type ping command then the result we like shown below and mark the netword card configuration is connected:

# ping localhost
localhost is alive
#

# ping xx.xx.x.x
xx.xx.x.x is alive
#

And now big mark question are? How possible, If we want to replace old ip address to new one with result any conflict or error? This stuff is going to discuss now, first we must to know that in Solaris OS hade two type configuration effect, which is temporary and permanent, when we chose to set the configuration temporary and if the server restarted then the configuration we already made before will lost and return to original configuration before the set, and when we chose to set permanently if the server restarted the configuration will stand still.

For temporary we can use this command: “ifconfig <interface> <ip address> <netmask> <broadcast address>” or if we use command above to real command become like this “ifconfig nge0 10.11.2.3 netmask 255.255.0.0”. After reconfigure ip address finish, then recheck using this command “ifconfig –a”, if the indicator show UP status it’s mean the configuration runs well. If not repeat this procedure until the configuration runs properly.

Beside temporary configuration we have permanent too, which evolved four file and the process outlined as follows, first we must to know the file evolved to this process are which one?

/etc/hosts
/etc/defaultrouter
/etc/netmask
/etc/inet/ipnodes

First file must to know is /etc/hosts if used “vi” command in unix shell then will produce snapshot like shown below, this written configuration below for three interface, which is “lo0”, “nge1” and “nge0”, for lo0 interface with default ip 127.0.0.1 and hostname “localhost” not necessary to change, cause it’s already default loopback system, for other interface beside lo0 still can change according with needed. We have “loghost” which mark this ip as default connection to network when system startup. If used ip address want to change into new ones just to change this “xxx” section. For “host-name” naming best way not to change it, followed first naming which already assign on first installation Sun Solaris System.

#
# Internet host table
#
127.0.0.1 localhost
xxx.xxx.xxx.xxx pc-server loghost
xx.xx.x.x pc-local

After /etc/hosts configure then specify which router will be taken as center for network connection in /etc/defaultrouter file, in this file contain one row only that specify IP address destination as router, change this line if you wish to change your default router.

If /etc/defaultrouter configure properly, then continue with /etc/netmask, as you can see below, this file specifying IP address as subnetmask installed in Solaris, for instance if you wish to use nge1 interface connect to gateway with this IP 192.101.0.160 and netmask written was 255.255.255.248 then this netmask will broadcast max in 192.101.0.167, so the gateway 192.101.0.160 only contain IP range between 161 to 167, while for nge0 interface if netmask set to this gateway 10.10.0.0 with netmask 255.255.0.0 then it will contain IP range between 1 to 255 in third segment and also 1 to 255 on the fourth segment.

#
# The netmasks file associates Internet Protocol (IP) address
# masks with IP network numbers.
#
# network-number netmask
#
# The term network-number refers to a number obtained from the Internet Network
# Information Center.
#
# Both the network-number and the netmasks are specified in
# "decimal dot" notation, e.g:
#
# 128.32.0.0 255.255.255.0
#
192.101.0.160 255.255.255.248
10.10.0.0 255.255.0.0

The last step before the restart is to change the system configuration files in /etc/inet/ipnodes, make necessary change to ip address in this file, in sample below configure make equal to /etc/netmask which ip address for “nge1” and “nge0” interface is 192.101.0.161 and 10.10.2.2, while for lo0 interface it’s already default would use 127.0.0.1, but for this configuration works make it equal with ip address contain in /etc/hosts.

After finishing all the stages in the Solaris network configuration settings then save all the files that have been configured, then restart the Solaris system, after start-up sequence is complete, then go to the unix console and give the command "ifconfig -a" and "netstat -rn", and look again at the status results of each interface is UP or not, if the configuration is correct UP and ready to connect to the network and another computer. Give the ping command to the gateway, if the status of "192.101.0.160 is alive" means all steps successfully, if not then repeat again the above process until finished.

#
# Internet host table
#
::1 localhost
127.0.0.1 localhost
192.101.0.161 suatu-server loghost
10.10.2.2 suatu-local

Maybe for now, only this knowledge can be shared with readers, and hopefully may be useful, if there is a shortage or entries which can improve please feel free to add comments.