Solved

Setting IP and default gateway without DHCP in Solaris

Posted on 2006-11-01
3
7,079 Views
Last Modified: 2013-12-21
Hello!

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!
0
Comment
Question by:CSecurity
  • 2
3 Comments
 
LVL 48

Assisted Solution

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

echo "1.2.3.4" >/etc/defaultrouter

where 1.2.3.4 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
0
 
LVL 3

Accepted Solution

by:
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.
/etc/defaultrouter

In my example below, I use the following:
IP address = 192.168.2.15
netmask = 255.255.255.0
default gateway = 192.168.2.1
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 192.168.2.15 netmask 255.255.255.0 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 192.168.2.1

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 0.0.0.0 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:
192.168.2.0   255.255.255.0

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!
0
 
LVL 3

Expert Comment

by:jhartzen
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.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.:

707 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now