Wise people learn when they can; fools learn when they must - Arthur Wellesley

Friday, 10 October 2014

IP Change in Solaris

                     
                           IP CHANGE


Well… Suppose I reached office and just got a call from Boss that we have few servers migrated from other locations and we need to setup them here,

Now what we have to do?

Before using we must have to bring them under our Network and have named them as per our convention.

Great… means in simple we have to change ip and hostname.

Let’s change them, but do remember 2 more parameters… if servers are coming from completely different network.

Gateway
Netmask



OK…

First need to check the Network details of server

root@sol-test-2:>/# ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
e1000g0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 192.168.234.134 netmask ffffff00 broadcast 192.168.234.255
        ether 0:c:29:48:1d:e7
e1000g0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 192.168.234.198 netmask ffffff00 broadcast 192.168.234.255
e1000g0:2: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 192.168.234.199 netmask ffffff00 broadcast 192.168.234.255



root@sol-test-2:>/# cat /etc/hosts
#
# Internet host table
#
::1     localhost
127.0.0.1       localhost
192.168.234.134 sol-test-2      loghost
192.168.234.198 sol-test-2
192.168.234.199 sol-test-2

root@sol-test-2:>/# cat /etc/defaultrouter [for gateway]
192.168.234.2


root@sol-test-2:>/# cat /etc/netmasks      [for netmask]
#
# 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.168.234.0   255.255.255.0

OK… So what we got?

System has 3 IP’s [1 physical and 2 virtual]  
 
All IP’s are well maintained in /etc/hosts

Gateway is 192.168.234.2

Netmask is 255.255.255.0


And new Details are

Physical IP     192.168.110.135
Virtual IP1     192.168.110.199
Virtual IP2     192.168.110.200

Gateway         192.168.110.2

Netmask         255.255.255.0


    
Let’s start changing them…

·         We need to encounter with only 1 file if there is only Physical IP is to change

/etc/hosts

·         But we have to alter 2 Virtual IP’s also, 1 file for each interface

/etc/hostname.<name of interface>

[Don’t worry if you don’t have any existing Virtual IP, Just Skip this step]


·         We also have new Gateway, so need to alter
/etc/defaultrouter

·         Though we have same Netmask, but have you noticed that it is attached with entire subnet/network, so we also need to alter
/etc/netmasks


Remember the situation; our server is from different Network. That’s why we need to change all details, if only IP has to be changed then just alter

/etc/hosts & reboot… done

Let’s start

**** Always remember to have console or sc login before ip change, never do it remotely****

root@sol-test-2:>/# ifconfig 192.168.234.134 down
root@sol-test-2:>/# ifconfig 192.168.234.198 down
root@sol-test-2:>/# ifconfig 192.168.234.199 down

root@sol-test-2:>/# vi /etc/hosts
::1     localhost
127.0.0.1       localhost
192.168.110.135 sol-test-2      loghost
192.168.110.199 sol-test-2
192.168.110.200 sol-test-2

root@sol-test-2:>/# vi /etc/hostname.e1000g0:1
"/etc/hostname.e1000g0:1" 1 line, 16 characters
192.168.110.199

root@sol-test-2:>/# vi /etc/hostname.e1000g0:2
"/etc/hostname.e1000g0:2" 1 line, 16 characters
192.168.110.200

root@sol-test-2:>/# vi /etc/defaultrouter
"/etc/defaultrouter" 1 line, 14 characters
192.168.110.2

root@sol-test-2:>/# vi /etc/netmasks
#               128.32.0.0 255.255.255.0
#
192.168.234.0   255.255.255.0
[we have above entry and need to be changed like…]

192.168.110.0   255.255.255.0

All changes are made… Now reboot the system


root@sol-test-2:>/#init 6

Let’s see what we did and what happened…

Though I did all these in VM, so I now I will not connect it through putty.


I will give snapshot of our changes…


All set…

Super,


No comments:

Post a Comment