1

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

user1527429
  • 111
  • 5

1 Answers1

1

First off, give your webserver a static IP on the internal network.

Next off, I guess you are using a DNS server on your network? In such case, just add the avalanche entry to point at webserver static IP

Frederik
  • 3,359
  • 3
  • 32
  • 46
  • Why can't I do this with dynamic IPs. Running bind would need a dedicated computer with a static IP running bind. I am not running bind on my network, and given that there is only one computer running Linux on the network, and it has a dynamic IP address, this makes it hard for other computers to reference the nameserver doesn't it. – user1527429 Jul 26 '12 at 17:37
  • I didnt really get that much of your response. From what I read, you dont have any DNS server on your network? It doesn't have to be BIND, but could be anything - even Windows. The reason why I told you to give the webserver a static IP is because that's best practice. Relying on DNS alone can be a bad thing. – Frederik Jul 26 '12 at 17:49