Hunter's blog

Working With Computers on a LAN

I have an old laptop that I installed Ubuntu server on and hooked up to my network. I've been using it for testing applications that might accidentally delete all of my files, but remembering its IP address is a hassle. I thought that it was possible to assign a name to my laptop which I could use to access it, so I set out to do that.

If you work with GNU+Linux machines, your probably familiar with the concept of a hostname. If you use bash, your prompt probably looks like name@hostname $. For example, my prompt is hunter@mars $. The hostname is how we will access this computer on our network, so you should change it to what you want. If you want to change your hostname, just edit /etc/hostname.

There are multiple ways to make our computer accessible by its hostname, but the easiest method is to make changes on our router. I have a Mikrotik hAP Lite, but the required changes should be similar on other routers. First you want to log in to your router's admin page, for me that means visiting 192.168.88.1 in my browser.

Our next step is to modify our DHCP server settings. On my router we go to IP -> DHCP Server -> Leases. My router lists all currently connected devices and their hostname, which makes this a lot easier. You may need to look up specific steps for your router, but if you need to find out your computer's IP address, run ip addr in your shell. Next I double click the device I want and select Make static. This means that whenever this device connects to the network it will be assigned the same IP address.

DHCP Server settings

The laptop we are working with has hostname mars and static IP 192.168.88.69.



Now that we have a static IP setup for the laptop internally, we need to make sure that the router sends requests for mars to the laptop. For this we want to modify the router's DNS settings. For my router we go to IP -> DNS -> Static. Click on Add New and set Name to your hostname and address to the laptop's internal IP address.

DHCP Server settings

Once again the relevant entry has name mars and address 192.168.88.69.



That's it! If you have a web server running on the computer you just set up, you can visit the hostname in your browser, or just run curl mars.