I've got an Ubuntu Linux server with a WiFi card. When I boot my computer apache web server starts and the /etc/hosts file lists which lists the following:
$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 avalanche
allows my server to be accessed from the same host using http:// localhost/ or http:// avalanche .
However, when I run ifconfig I get the following output:
wlan0 Link encap:Ethernet HWaddr cc:af:78:bf:28:45
inet addr:192.168.3.31 Bcast:192.168.3.255 Mask:255.255.255.0
inet6 addr: fe80::ceaf:78ff:febf:2845/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:565796 errors:0 dropped:0 overruns:0 frame:0
TX packets:360709 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:620453848 (620.4 MB) TX bytes:46274848 (46.2 MB)
So, I would like browsers on my internal network to be able to access the apache server not only with http:// 192.168.3.31 but also by http:// avalanche/ . This means I must add the following mapping in /etc/hosts :
192.168.3.31 avalanche
but I don't want to have to have to do it by hand every time the machine boots, but at the same time the IP address the router assigns, AFAIK is a dynamic IP address, so it changes all the time, so I cannot just hardcode an IP in the /etc/hosts file.
So, my question is, what is the best way of adding this mapping dynamically when the machine boots up?
Thanks,
John Goche