0

I run Apache on my Macbook Pro for off-line use of a web app. But for "self-defense" online, I use /etc/hosts to map certain hostnames to 127.0.0.1 which means if a webpage causes a GET to one of these, it hits my local webserver instead.

I would rather they do nothing. If I point them to an address that I know is unreachable, e.g., 10.250.250.250, then a poorly designed web page may not render until the GET times out.

In 10.13.4, how do I (Can I) point them to a separate private address that will be handled on the Macbook and set that address to immediately reject everything? (Without changing how loopback behaves.)

(By the way, Apple documentation has long claimed that /etc/hosts is only used in single-user mode. I have found that to be false on many versions of OS X/MacOS.)

  • Can you change the port number for your local Apache instance? – Mike Scott Apr 24 '18 at 8:51
  • Actually, that could be done, thanks. It would have the added bonus of making it harder for someone to get in from outside. Still would like to know about the other, though. – WGroleau Apr 24 '18 at 13:15
  • How is this "multi-homed"? There's not two or more discreet networks here. – Allan Apr 24 '18 at 15:11
  • 127.0.0.1 already exists. If I add another address (somehow), isn't that multi-homed? – WGroleau Apr 24 '18 at 15:17
  • 127.0.0.1 is a loopback not a network – Allan Apr 24 '18 at 15:55
2

The easiest way to achieve a guaranteed reject with no timeout is to use a broadcast address 255.255.255.255. Edit your /etc/hosts file and for hosts that you want request rejected put an entry such as:

255.255.255.255  rejectedhost.com
255.255.255.255  someotherhost.net

This free and simple technique can also be used to block out advertisement hosts on ad-ridden or popup-ridden web pages.

  • Although it doesn't technically answer the question, I'm accepting it because it is a better solution than the one I asked about. Thanks – WGroleau Apr 24 '18 at 16:27
  • Great technique, thank you. I'm using it to block popunders. – jetset Jul 30 '18 at 21:41

You must log in to answer this question.

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