0

I am developing a web server on a microcontroller and use W5500 chip from Wiznet for access to Ethernet. Right now in order to access the web pages, on the browser I have to type in the ip address of the server. How do I give it a hostname, so instead of ip address I can enter the hostname in the browser?

I already have a working server.

HV16
  • 25
  • 5
  • 2
    The simple answer is add the server to your computer's hosts file (/etc/hosts on linux), but that will only work on each machine you add that IP address to. For more robust options check out [DNS](https://www.google.com/search?q=running+a+dns+server) or possibly [NetBIOS](https://en.wikipedia.org/wiki/NetBIOS) but I would suggest DNS if that is an option. – M Virts May 12 '23 at 01:07
  • To access a server from outside the network with a hostname instead of IP, you may need to buy and configure a domain. If you don't want to pay, use a service like No-Ip that give you a subdomain. Just complementing what @M Virts said since he is right, too. – Jorge Pérez May 12 '23 at 01:16
  • @JorgePérez I only need to access from a computer on the same home network. – HV16 May 12 '23 at 01:22
  • Can I let the DHCP server on the network know to route to the ip address when someone type the given name on the address bar in web browser – HV16 May 12 '23 at 01:25
  • I agree with M Virts that you should use DNS, accordingly to your network architecture. If you have admin access to your router/gateway, there you can configure DNS easily (just inserting ip-hostname pairs. – Jorge Pérez May 12 '23 at 01:34
  • do you know any source for tutorials on how to configure DNS? Something like what the frame looks like. I am learning Ethernet so haven’t got much experience on this – HV16 May 12 '23 at 01:45
  • as the user asked about embedded device, the The hosts file is not the best option. The user must be expecting the same option as available in SOHO grade routers webcams which are accessible by hostname written on them. – Asim Kumar Mahakul Jul 27 '23 at 08:53

1 Answers1

0

This is the thread (https://superuser.com/questions/1093419/alias-for-ips-in-the-home-lan-network#1093639) but it's not as easy as i thought it would be. I recommend the easy simple answer M Virts mentioned (edit /etc/hosts in linux, C:/Windows/System32/drivers/etc/hosts in Windows) but you must edit this file for each computer you want it to work with. For example, if your server's network ip is 192.168.0.3, in your other computer you should add a similar line like this:

192.168.0.3 myserver.test

Then you should be able to access your server from the browser by entering "myserver.test"

Jorge Pérez
  • 234
  • 1
  • 5