-2

I am building a small linux box, which will be running a webserver only. The purpose of this little machine is to be put into a small, temporary network at a temporary location with no access to the internet, serving the webservice to the local network

The question is, how do the clients discover the address of the machine?

Static IP is not ideal, since it should be able to run on any local network, so DHCP is pretty much a must. Running dns and dhcp server from the box is an option, though not preferable, since the network may already have such a service, and the box would conflict with it.

These are the only ways I can think of though. Any other ideas?

Eldamir
  • 179
  • 1
  • 10

2 Answers2

2

You could use nmap to scan the network. If for example your web server runs on tcp:80 and your subnet is 192.168.1.0, then you can try :

nmap 192.168.1.0/24 -p 80

on my network I get

Starting Nmap 6.47 ( http://nmap.org ) at 2015-04-27 19:36 AEST
Nmap scan report for 192-168-1-1.tpgi.com.au (192.168.1.1)
Host is up (0.022s latency).
PORT   STATE SERVICE
80/tcp open  http

Nmap scan report for 192-168-1-8.tpgi.com.au (192.168.1.8)
Host is up (0.00011s latency).
PORT   STATE  SERVICE
80/tcp closed http

So you can see that that there is a web server on the address 192.168.1.1 (it's my route). You can also see that there is another machine on the network, but that it has port 80 closed, so that it's not a web server

YBounya
  • 71
  • 3
2

Make sure you set the hostname for the computer. Assuming that every network you connect to runs its own DNS/dhcp then when its gets a dhcp address it should (in a normal setup) register its hostname with the local DNS server automagically

So set it as MYAWESOMEWEBSERVER and tell all your clients to hit up that hostname and magic (most browser's just type in http://myawesomewebserver and the browser do a DNS and gt a local IP)

On most Linux computers just edit /etc/hostname to set hostname

edit for most robust/redundant build I would suggest you have a startup script to test LAN for active dhcp/DNS services (if so accept dhcp address) and if not, to start DNS/dhcp server locally and apply a static ip

mrwhale
  • 146
  • 3
  • Indeed, but I cannot assume that the network will have dhcp and dns, unfortunately – Eldamir Apr 27 '15 at 10:26
  • 1
    Quite a pickle you have there. You could always have a startup script that attempts DHCP and if that fails, set static IP and start your own DNS – mrwhale Apr 27 '15 at 10:28
  • Hmm. Interesting. So my server will check if there are dhcp and dns services on the local network, and if not: run them itself. Thats actually a good approach, albeit it will take some work – Eldamir Apr 27 '15 at 10:30
  • Yeah correct, this would be the most redundant/robust approach, but yes would just need some tinkering to get working! – mrwhale Apr 27 '15 at 10:33
  • I agree. If you update your answer to reflect this discussion, I'll mark it as accepted – Eldamir Apr 27 '15 at 10:34