LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 09-24-2008, 04:07 AM   #1
chandanbhosle
LQ Newbie
 
Registered: Nov 2007
Posts: 5

Rep: Reputation: 0
How to configure /etc/hosts in OpenSolaris


Hi,
I am using OpenSolaris, I have configured my system with DHCP.
My problem is the /etc/hosts in not getting updated whenever the new IP has been assigned.I have to make an entry every time in the /etc/hosts whenever a new IP is assigned. Actually I am doing a project on Network Monitoring System, In which I retrieve the host name and the Host Address to monitor it.

This is my /etc/hosts entry

127.0.0.1 loghost solaris
172.1.3.90 loghost solaris

In which i have entered 172.1.3.90. And I have to change ts entry every time a new IP is assigned to my Network Interface. I query the Host address in my program as

String Hostname = InetAddress.getLocalHost().getHostAddress();
System.out.println("The Hostname is :"+Hostname);

This always prints "172.1.3.90", even though the IP is changed.

As per my understanding, the /etc/hosts should be updated dynamically with DHCP, but its not happening.

Please help me in resolving this problem.

Thanks
-Chandan
 
Old 09-24-2008, 10:17 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by chandanbhosle View Post
Hi,
I am using OpenSolaris, I have configured my system with DHCP.
My problem is the /etc/hosts in not getting updated whenever the new IP has been assigned.I have to make an entry every time in the /etc/hosts whenever a new IP is assigned. Actually I am doing a project on Network Monitoring System, In which I retrieve the host name and the Host Address to monitor it.

This is my /etc/hosts entry

127.0.0.1 loghost solaris
172.1.3.90 loghost solaris

In which i have entered 172.1.3.90. And I have to change ts entry every time a new IP is assigned to my Network Interface. I query the Host address in my program as

String Hostname = InetAddress.getLocalHost().getHostAddress();
System.out.println("The Hostname is :"+Hostname);

This always prints "172.1.3.90", even though the IP is changed.

As per my understanding, the /etc/hosts should be updated dynamically with DHCP, but its not happening.

Please help me in resolving this problem.

Thanks
-Chandan
To my knowledge, the /etc/hosts file won't change with a DHCP change. When the system is booted, it'll request a new address, and configure the interface accordingly. Depending on the search order, you'll either look at DNS or hosts first. If you do a query, and it succeeds with a host file lookup, it stops there, because it found what it needed.

Remove the line from /etc/hosts, and try it.
 
Old 09-24-2008, 03:43 PM   #3
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Your /etc/hosts is bogus. 127.0.0.1 should have localhost as primary name, only one loghost alias should be there and solaris should resolve in a single IP address.

I guess nwam might update your /etc/hosts file but your dhcp server should provide a hostname along with the IP address for this to work (if nwam does it really).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
configure OpenVPN for two hosts in same LAN Buddhike G Linux - Networking 2 02-05-2008 11:44 PM
SuSE 9.2 - apache2 & tomcat5 - how to configure VIRTUAL HOSTS & JSP? nicolasdiogo Linux - Networking 2 03-20-2005 08:06 AM
Configure virtual hosts in Apache 1.3.26 @ngelot Linux - Software 3 03-10-2005 02:13 AM
How to configure DHCP client at server /etc/hosts ? x2000koh Linux - Networking 1 08-06-2003 03:02 AM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 05:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration