Wednesday, November 12, 2014

Change IP address and netmask in Solaris 11





[root@server:/ ]$ ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
net0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 32.119.202.220 netmask fffffff8 broadcast 32.119.202.223
ether 0:10:e0:f:d5:16
net8: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 4
inet 169.254.182.77 netmask ffffff00 broadcast 169.254.182.255
ether 2:21:28:57:47:17



List current IP setting:

[root@server:/ ]$ 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
net0 ip ok -- --
net0/v4 static ok -- 32.119.202.220/29
net0/v6 addrconf ok -- fe80::210:e0ff:fe0f:d516/10
net8 ip ok -- --
net8/v4 static ok -- 169.254.182.77/24 <-----------change this
[root@server:/ ]$





Let's chage netmask on interface net8/v4 to /29:





[root@server:/ ]$ ipadm set-addrprop -p prefixlen=29 net8/v4






[root@server:/ ]$ 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
net0 ip ok -- --
net0/v4 static ok -- 32.119.202.220/29
net0/v6 addrconf ok -- fe80::210:e0ff:fe0f:d516/10
net8 ip ok -- --
net8/v4 static ok -- 169.254.182.77/29 <---------------changed
[root@server:/ ]$



Confirm:


[root@server:/ ]$ cat /etc/ipadm/ipadm-DefaultFixed.conf
_ifname=lo0;_aobjname=lo0/v4; _ipv4saddr=string,127.0.0.1;prefixlen=string,8;up=string,yes;
_ifname=lo0; _family=string,2,26;_class=uint64,2;
_ifname=lo0;_aobjname=lo0/v6; _ipv6saddr=string,::1;prefixlen=string,128;up=string,yes;
_ifname=net0; _family=string,2,26;_class=uint64,0;
_ifname=net0;_aobjname=net0/v4; _ipv4saddr=string,32.119.202.220;prefixlen=string,29;up=string,yes;
_ifname=net0;_aobjname=net0/v6; _intfid=string,::;prefixlen=string,0;_stateless=string,yes;_stateful=string,yes;
_ifname=net8; _family=string,2,26;_class=uint64,0;
_aobjname=net8/v4;_ifname=net8; _ipv4saddr=string,169.254.182.77;up=string,yes;prefixlen=string,29;








[root@server:/ ]$ ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
net0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 32.119.202.220 netmask fffffff8 broadcast 32.119.202.223
ether 0:10:e0:f:d5:16
net8: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 4
inet 169.254.182.77 netmask fffffff8 broadcast 169.254.182.79
ether 2:21:28:57:47:17




Converersion from Solaris HEX format:


fffffffc 255.255.255.252 /30
fffffff8 255.255.255.248 /29
fffffff0 255.255.255.240 /28
ffffffe0 255.255.255.224 /27
ffffffc0 255.255.255.192 /26
ffffff80 255.255.255.128 /25
ffffff00 255.255.255.0 /24
fffffe00 255.255.254.0 /23
fffffc00 255.255.252.0 /22
fffff800 255.255.248.0 /21
fffff000 255.255.240.0 /20
ffffe000 255.255.224.0 /19
ffffc000 255.255.192.0 /18
ffff8000 255.255.128.0 /17