Use /etc/hosts to direct wildcard domain name
Solution 1
You need to set up a DNS server. (install dnsmasq (is light) or bind (is rather heavy)). To install ...
sudo apt-get install dnsmasq
In /etc/NetworkManager/dnsmasq.d/dnsmasq-localhost.conf
add
address=/localhost.com/127.0.0.1
restart
sudo /etc/init.d/dnsmasq restart
Important note.
If dnsmasq
service failed to start, please check your service logs by running systemctl status dnsmasq.service
command.
Then, If you will see the following message in the logs Failed to create listening socket for port 53: Address already in use
- you may resolve this error as described here
Solution 2
Just a quick addition to the above answer, make sure that your local domain name DOES NOT end with .local
, it looks like this is a reserved name so in your /etc/dnsmasq.conf
:
address=/somesite.local/127.0.0.1
WILL NOT WORK
address=/somesite.loc/127.0.0.1
will work.
Related videos on Youtube
Buck
Hacking at Ubuntu to build a Portable USB VM Server My current learning task for my Winter/Spring goal is to set my laptop up as a VirtualBox server serving Lubuntu and Windows 7, then get it to work from a USB Live stick. =========================================================================================== My goal for the Winter/Spring seasons of 2018 are to set up my laptop as a VM server serving Windows 7 and various other operating systems that I can access remotely from any home computer or from my laptop away from home (assuming I get a new laptop, LOL) I am hoping that the server can be configured on a USB stick and that I can use an external USB drive for the VM images. My fallible theory is that I can move it to whatever computer I want to use it from. (I believe it won't work as every computer in the house is a different brand.) ========================================================================================== I started with Ubuntu 8 back about the time Vista was becoming infamous. I upgraded to 9 and 10 and then stayed with LTS versions until version 16.04 LTS kept crashing on my SSD. I went back to Windows 8.1 which I upgraded to 10 in August of '16. This year, '18, I am hoping to set up a 'buntu based VM server. My skill level is adequate for the most part, but I probably only teeter on the edge of becoming a power user as I only use CLI when and as I am instructed. I do as much as I can through the GUI. This January of '18, I broke the screen on my laptop and attached it to an external monitor. I have installed Lubuntu 16.04 LTS but plan to install 18.04 as soon as possible. It is currently the only OS on the system, so I have it installed in BIOS mode rather than EFI, which I hope to avoid if possible.
Updated on September 18, 2022Comments
-
Buck over 1 year
I searched this term and didn't find my answer: "wildcard domain name in hosts"
I have a HostGator account where I create secret domains so I can build and test websites. In order to use them, I add the domain to my /etc/hosts file like:
192.168.129.3 ts.buck 192.168.129.3 www.ts.buck
I tried using the *
192.168.129.3 *.buck
but it doesn't work.
This is on my desktop, I don't have a server here. It is also for internal use only, not for the rest of the world to see or access.
It would be nice to have a simple way to use my own TLD for building test sites.
-
muru about 8 years
-
Rinzwind about 8 yearsYou could have made an answer and I would have upvoted you ;)
-
Buck about 8 yearsShould I have clarified that I searched "askubuntu"?
-
Buck about 8 yearsexplain why the negative?
-
Rinzwind about 8 yearshere I put it back to 0 ;-) and to the 1st comment: probably, That 1st line can tick people the wrong way when they find a results within seconds ;-)
-
-
Buck about 8 yearsThis was a very easy fix and very simple answer. Much better than the pages in the links. I wish I had asked this years ago.
-
Buck about 8 yearsI added the line: address=/.buck/192.168.129.3 to dnsmasq-localhost.conf. This did the trick.
-
Buck about 8 yearsThanks, I didn't mean to override your answer, just clarify the added line without editing your answer. WOW, I am happy.
-
Rinzwind about 8 yearsOh you are welcome to edit anything important into this answer ;-)
-
Fabby about 8 years@Buck As you've never accepted an answer on this site before: If this answer helped you, don't forget to click the grey ☑ at the left of this text, which means Yes, this answer is valid! ;-)
-
Buck about 8 yearsThank you, I didn't know how to do that. Thank you and Bless You!
-
Josh.F over 7 years
sudo service network-manager restart
: make sure to restart the network manager too :) -
Taylan over 7 yearsFor Ubuntu 16 use this to restart network manager
sudo systemctl restart NetworkManager.service
-
muru almost 7 yearsIf you have an addition to that answer, suggest an edit: askubuntu.com/posts/743051/edit
-
Jeff over 6 yearsI dont have the
dnsmasq.d/
directory after theapt-get
. The only thing I have underNetworkManager
isdispatcher.d/hook-network-manager
. Should I manually create that folder and file? (Ubuntu 16.04) -
George Dimitriadis about 6 yearsAlso "above answer" can become irrelevant after a while
-
peter about 6 yearsDo I need to add something to my /etc/hosts file?