uncategorized

Static IP in OpenSolaris 2009.06

Based on instructions from http://dd-b.net/ddbcms/2009/01/opensolaris-static-ip/

1
2
3
4
5
pfexec bash
MYIP=192.168.1.5
MYSUBMASK=255.255.255.0
MYROUTER=192.168.1.1
MYHOST=$( hostname )

Find your network interface (hint, not lo0):

1
MYNIC=$( ifconfig -a | grep -v lo0 | grep IPv4 | sed 's/:.*//g' )

Enable network, disable NWAM:

1
2
svcadm enable physical:default
svcadm disable physical:nwam

Backup hosts file:

1
cp /etc/hosts /etc/hosts.bak

Comment existing, populate with 2 entries:

1
2
3
4
cat /etc/hosts.bak | sed 's/^/#/g' > /etc/hosts
echo "::1 localhost loghost ip6-localhost" >> /etc/hosts
echo "127.0.0.1 localhost loghost" >> /etc/hosts
echo "$MYIP $MYHOST $MYHOST.local" >> /etc/hosts

Check that you have DNS servers in /etc/resolv.conf, otherwise, overwrite with the Google and OpenDNS ones:

1
2
3
4
5
6
cp /etc/resolv.conf /etc/resolv.conf.bak
cat /etc/resolv.conf.bak | sed 's/^/#/g' > /etc/resolv.conf
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
echo "nameserver 8.8.4.4" >> /etc/resolv.conf
echo "nameserver 208.67.222.222" >> /etc/resolv.conf
echo "nameserver 208.67.220.220" >> /etc/resolv.conf

Tell name server service to look at DNS for hosts:

1
cp /etc/nsswitch.dns /etc/nsswitch.conf

Save nic settings in file:

1
2
3
HOSTNIC=/etc/hostname.$MYNIC
echo "$MYIP" > $HOSTNIC
echo "netmask $MYSUBMASK broadcast + up" >> $HOSTNIC

Manually set IP:

1
ifconfig $MYNIC $MYIP netmask $MYSUBMASK up

Add default route:

1
2
route add 0.0.0.0 $MYROUTER
echo "$MYROUTER" > /etc/defaultrouter

Check that your default gateway/router is marked as default:

1
netstat -rn

Check that your IP is set:

1
ifconfig $MYNIC
Share