3

Is possible setup multiple .local hostname on one physical computer?

Background:

  • home network (behind the DSL/NAT router) (192.168.1.*)
  • have a mac-mini, called as "tango.local". (set in the System.prefs). The IP-setting is "use DHCP with manual address" - the computer address is 192.168.1.10.

Now, on this mac want run apache2 (macports version), with different VirtualHost directives, like:

<VirtualHost *:80>
    ServerName tango.local
    ProxyPass / http://localhost:5000/
    ProxyPassReverse / http://localhost:5000
</VirtualHost>
<VirtualHost *:80>
    ServerName another.local
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000
</VirtualHost>

For this setup I need assign two different hostnames to the mac, e.g. the main tango.local and the another.local. Both names should be resolve-able from the LAN, e.g. computers on the LAN (my mac-notebook) must correctly resolve the http://another.local/ address.

It is possible to do this with simple way, (e.g. somewhat convience the bonjour to advertise both names for the single IP), or need setup the bind DNS server for serving the .local domain?

Bonus question: the main goal is resolve the another.local from another mac (via bonjour). Secondary: what i need setup to allow access the http://another.local from an windows7 notebook? (i'm total windiot - e.g. is possible somewhat convert bonjour names-addresses to the "windows nmbd" or whatever?

  • Hey, I've updated my answer below after realising it's totally possible to register multiple .local names simply by using the dns-sd proxy option. – Asmus Feb 20 '15 at 8:12
2

I think you don't need to register a new hostname if you're just about publishing web services. On the Mac, you can register a new website with bonjour on the command line with

dns-sd -R "My Website" _http._tcp . 80 path=/path-to-page.html

you can verify that it worked by using Safari's bonjour menu or on the command line with

dns-sd -B _http._tcp

Bonjour for Windows is available (and is, I think, included when installing iTunes).

If for some reason you actually need specific host names, you could consider using dnsmasq (can be installed with homebrew or macports) to reroute your specific hostnames only (using your default DNS for everything else) and telling your Windows computer to use your Mac as its DNS server.


Update:

I failed to realise it's totally possible, you can indeed register multiple .local hostnames with bonjour, do it as a proxy like this:

dns-sd -P myService1 _http._tcp local 80 server1.local 127.0.0.1 path=/path/to/service1
dns-sd -P myService2 _http._tcp local 80 server2.local 127.0.0.1 path=/path/to/service2

Here you're registering two services (myService1,-2) running on the same server (127.0.0.1, within different server paths) on port 80 as two different .local names.

  • 2
    Note that using "127.0.0.1" will make the hostname work like "localhost" on all local machines. If you want to connect to the new hostname from another machine on the network, use its LAN IP address. – RTS - read about Monica Cellio Nov 2 '16 at 16:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .