On Debian (and most Linux distributions), you can define an Internet host alias (a hostname that resolves to an IP address) by editing the /etc/hosts file. This is useful for testing, local development, or creating shortcuts for frequently accessed hosts.
Open the /etc/hosts file with a text editor (you need root privileges):
bashsudo nano /etc/hosts
(You can use vim, gedit, or any other editor instead of nano.)
Add your alias in the following format:
<IP_address> <hostname> [aliases...]
For example, to alias myserver to 192.168.1.100, add:
192.168.1.100 myserver
You can also add multiple aliases for the same IP:
192.168.1.100 myserver myserver-alias
Save the file and exit the editor.
Test the alias by pinging or using the hostname:
bashping myserver
(If the alias works, it should resolve to the IP you specified.)
/etc/hosts take effect immediately.myserver.local), ensure your system is configured to resolve .local domains (commonly used for local networks).This Chat is read-only. Login to resume chatting.