On Thu, Feb 19, 2009 at 8:58 AM, Patrick Maia <[email protected]>wrote:
> > > > On Feb 18, 4:21 pm, Christopher Stamper <[email protected]> > wrote: > > On Wed, Feb 18, 2009 at 2:16 PM, Patrick Maia > > <[email protected]>wrote: > > > > > > > > > Hi all, I have a virtual machine with Ubuntu 8.10 installed. This > > > machine is using DHCP to configure its IP address. My problem is that > > > every time the IP address changes my /etc/hosts file isn't > > > automatically updated and I have to do it by hand. I'd like to know if > > > is there a way to automatically update this file when the IP changes. > > > > Why do you wan to update this file? Do you really understand what it is? > > I think this file keeps a map of some hostnames/IP addresses, and > according with the configuration in host.conf the system could use it > to resolve names before asking an external source. My problem with > this is that I have a java application that needs to know the IP > address of the machine on which it is running. If the /etc/hosts file > contains just the line "127.0.0.1 localhost", my application gets an > error cause it can't resolve the machine's name. I can solve this > problem if I add a line with the machine's IP and its name but, as I > said, every time the IP changes I need to go there and put the new IP > in order for my application to properly run. That's why I want to > automatically update /etc/hosts. > Well, I think you could write a simple shell script that would fix it for you. Something that would 'grep' the IP from 'ifconfig', and write it to hosts.conf. I'm not a scripting expert, but it should be pretty simple... -- Christopher Stamper Email: [email protected] Web: http://tinyurl.com/2ooncg gTalk: http://tinyurl.com/6e359r Skype: cdstamper --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ubuntu Linux" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/ubuntulinux?hl=en -~----------~----~----~----~------~----~------~--~---
