Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Setting IP and default gateway without DHCP in Solaris

Posted on 2006-11-01
Last Modified: 2013-12-21

I have Solaris Sun OS 10 installed. I can set my default gateway and IP address dynamically by DHCP in my network (DHCP runs under windows).

But now I want to set a static IP, static gateway's IP and static sub domain and I want to have internet connection from the gateway I'll define.

I know something about defaultrouter and gateways file in /etc...

But I need step by step and a good example...

Please advice!

Thanks from now!
Question by:CSecurity
  • 2
LVL 48

Assisted Solution

Tintin earned 200 total points
ID: 17852989
To set your default gateway, do

echo "" >/etc/defaultrouter

where is your default route.

Make sure you have the correct IP address for your server in /etc/inet/hosts and /etc/inet/ipnodes

Then find out your interface name by doing

ifconfig -a

It will be something like bge0, ipge0, hme0 etc.

then put the hostname in /etc/hostname.<int>, eg:

echo "myhost" >/etc/hostname.bge0

then if you have a non-standard netmask, add it to /etc/netmasks.

If you use DNS, then add

nameserver <ip of your nameserver>

in /etc/resolv.conf

Accepted Solution

jhartzen earned 300 total points
ID: 17857275
Hi there Csecurity.

The answer by Tintin points you to the configuration files, but I would like to add a few things.  Firstly, just changing the config files will not set the IP address, gateway, netmask, etc, unless you also reboot or cycle through init s -> init 1 -> init 2.  Secondly, if you make a mistake while changing the network config, you can lose connectivity.  If you did not change the config files, you would be able to revert to the working config by rebooting.  Therefore I recommend first trying out the config using the config commands, and once it works, set it in the config files to make the changes permanent.

The files, as mentioned above, are:
/etc/inet/hosts (a link exists with the name /etc/hosts)
/etc/inet/netmasks (a link exsits with the name /etc/netmasks)
/etc/hostname.bge0 or /etc/hostname.ce0 or ... depending on your specific network card.

In my example below, I use the following:
IP address =
netmask =
default gateway =
Interface = bge0

If it is a new interface, first you must plumb the port, like this
> ifconfig bge0 plumb
(Note: this will fail if the port is currently plumbed)

Then set the network address
> ifconfig bge0 netmask broadcast +
(Note: More on the use of the "+" later)

If the interface is not yet up, eg if it was new, then bring it online:
> ifconfig bge0 up
(no harm in doing this on an already online interface.  You can temporarily offline an interface by using "down", which updates your dynamic routing tables, refreshes your ARP cache, etc.  Very handy hint, that last bit of info, by the way)

Now add a default gateway - This requires an "online" interface within the same subnet as the gateway address!
> route add default

Check your config: To show the interface IP address, netmask, etc, on all interfaces, use:
> ifconfig -a
(Note: carefully check that the first flag is the word "UP", missing flags means that the flags are not set)

Also check your routing:
>netstat -rn
(Note: Unless you have very specific requirements, there should be exactly one entry called "default")

Test your configuration.
ping the interface - proves that it is "up".
ping the default gateway - proves that you have a working link.
ping a machine on another subnet - proves that your default router is correctly set up.

Now that you have verified the setup, you can put all the settings into the config files.  Also remove the file /etc/dhcp.bge0 (depending on your interface type, the bge0 part could be something like eri1, qfe0, hme1, ce3, bge5, or many other types.)

Some hints:
Firstly: Later versions of solaris (since Solaris 9) allows you to automatically plumb all the interfaces present in the system, without having to guess what interfaces are present.  try
> ifconfig -a plumb
(ignore the errors for already plumbed interfaces) followed by
> ifconfig -a
this will list newly plumbed interfaces with as the address.

alternatively, discover network interfaces in the system with this command:
> grep network /etc/path_to_inst
(Note: With earlier versions of solaris, before solaris 8 in particular, your mileage will vary)

Second hint: Once you have the netmask set in the /etc/netmasks file, you can use a "+" so that the ifconfig command will fill in the netmask automatically based on the IP address you specify.  You can also almost certainly let the ifconfig command figure out the broadcast address by using a "+" in this field, to let the ifconfig command use the netmask and IP address together to work out the correct broadcast address.

Some hints on updating the config files:
for netmasks, add entries to the file using the network address followed by the netmask, both in dotted-decimal notation, eg:

The /etc/defaultrouter file must contain an IP address, not a hostname.

Having the wrong address for your host in /etc/hosts will cause X-windows to misbehave.  Make sure that the IP address/hostname pair refer to a live network interface!

DHCP might be providing you with DNS information.  You will lose this when you switch to using a static IP address.  Find your DNS server addresses, and do the following:
a) add a server line to /etc/resolv.conf for the DNS server(s)
b) make sure that the line in /etc/nsswitch.conf for "hosts" include the word "dns" at the end of the line.
c) reboot or send a HUP signal to the nscd process.

And always make backups of your config files before you modify them!

Expert Comment

ID: 17864712
One final thought from me:  It is good practice to release the DHCP lease prior to going to a fixed IP address, eg
> ifconfig bge0 release

This will inform the DHCP server that it can add that address back into its free pool.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ACL in Solaris 10 & AIX V6.1 to circumvent application required  grp:rwx 9 116
how to check for shares on aix 1 85
ftpcommand 2 66
OpenLDAP Proxy to Active Directy 6 361
Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question