how to update /etc/hosts when dynamic ip changes
Ok, I don't really understand all this, newbie to linux and all, but..
I think I need to update my /etc/hosts file so that there is always a line where 127.0.0.1 is mapped to what I think is my current ip address (I have a dynamic ip) in IPv6 format, like below..
how best make it happen? Updating a text file doesn't sound too elegant in the first place, there is a much more sophisticated way doing this? There was some talk about name servers in the /etc/conf comments..
If you are interested why the need for this, I hit into a little bit of a problem with my Suse 10.1, as in java (5) a simple call to resolve the local host (InetAddress.getLocalHost()) results in an UnknownHostException: dnaXX-XXX. To me that dnaXX-XXX (where X's are numbers), which also reads in my console as the prompt, didn't look like an internet address I'm used to so I thought to myself it ought to be one of those IPv6 addresses. And If I've understood correctly what I've read so far that's excactly what it was and the problem is a linux jdk bug got something to do with IPv6. To make it all go away, I read the way to go is to disable IPv6 from the kernel (did that), start the java program with a property -Djava.net.preferIPv4Stack=true (tried), and finally, to check if /etc/hosts is as it should be. I had no idea what all the lines in my /etc/conf were supposed to mean so I just tested adding a line like above with the current address and it worked. Maybe you find out the problem in my /etc/hosts and I need not actually add a line but remove some? -I tried commenting all them ipv6 related lines out but that had no effect. The file reads as follows :
# special IPv6 addresses
::1 localhost ipv6-localhost ipv6-loopback
127.0.0.2 linux-okdi.site linux-okdi
Long post, srry. And thanks in advance..