I recently discovered lando for local web development, which uses docker in the background. It works great so far, but I have to add every domain for each project manually to my hosts file
/etc/hosts
:
127.0.0.1 myproject.local.host
127.0.0.1 bs.myproject.local.host
127.0.0.1 bs-admin.myproject.local.host
(the bs.
and bs-admin.
ones are for browsersync)
According to the lando docs, it is possible to have a wildcard domain instead of hard coding every domain. Unfortunately are those instructions for MacOS and I am on Arch Linux (Manjaro Gnome 41.3).
I tried to figure it out myself with the help of the page Arch Wiki: Dnsmasq and other online resources but I couldn't get it to work.
This is what I currently have:
- installed Dnsmasq
sudo pacman -S dnsmasq
- added these lines to the
/etc/dnsmasq.conf
file (everything else in the file was/is commented out):listen-address=::1,127.0.0.1 expand-hosts domain=local.host
- restart local server
sudo systemctl restart httpd
andsudo systemctl restart dnsmasq
- added this line to
~/.lando/config.yml
domain: local.host
- restart lando
lando poweroff
andlando start
However, it does not work:
❯ ping http://myproject.local.host:8000/
ping: http://myproject.local.host:8000/: Name or service not known
❯ ping http://myproject.local.host
ping: http://myproject.local.host: Name or service not known
❯ ping https://myproject.local.host
ping: https://myproject.local.host: Name or service not known
Adding these lines to /etc/resolv.conf
didn't help either:
nameserver 127.0.0.1
Update:
I'm still very confused how dnsmasq.conf
(dnsmasq.d
), etc/hosts
, etc/resolv.conf
and /etc/systemd/resolved.conf
interact with each other. But after more reading and trial&error, this is were I am currently:
- added this line to
/etc/dnsmasq.conf
:address=/local.host/127.0.0.1
- no added lines to
/etc/hosts
These lines were in there from StevenBlack/hosts127.0.0.1 localhost 127.0.0.1 localhost.localdomain 127.0.0.1 local 255.255.255.255 broadcasthost ::1 localhost ::1 ip6-localhost ::1 ip6-loopback fe80::1%lo0 localhost ff00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts 0.0.0.0 0.0.0.0
- added this line to
/etc/resolv.conf
:nameserver 127.0.0.1
- ran
sudo systemctl restart NetworkManager
andsudo systemctl restart dnsmasq
- added this line to
~/.lando/config.yml
domain: local.host
- ran
lando poweroff
andlando start
When I test it, I get this:
❯ nslookup foo.local.host localhost
Server: localhost
Address: ::1#53
Name: foo.local.host
Address: 127.0.0.1
❯ nslookup foo.local.test
Server: 192.168.2.1
Address: 192.168.2.1#53
** server can't find foo.local.test: NXDOMAIN
❯ ping foo.local.host
ping: foo.local.host: Name or service not known
lando start
shows the top two urls in green and the bottom two in red:
APPSERVER URLS https://localhost:49291
http://localhost:49292
http://myproject.local.host:8000/
https://myproject.local.host/
dnsmasq.conf
, the one from the guide. Is that intentional?address=/local.host/127.0.0.1
? I tried that before, but that did not work. I assumed the lines I have in the post you do something similarnslookup foo.local.host localhost
works, butnslookup foo.local.host
not?