Hit the url "www.example.com" and it always return the router's home geteway page back. I forwarded port 80 to my local server IP address. Googling didn't help much so please kindly help me with this!

DNS records:

        Host   Points to
CName   www    @
 A      @      my public IP address

Created example.com.conf file for Apache, configured as:

<VirtualHost *:80>
    DocumentRoot /var/www/example.com/
    ServerName example.com
    ServerAlias www.example.com

Edited the file /etc/hosts  example.com

Created a text file under /var/www/example.com/test.txt, hit url http://www.example.com/test.txt and it responds with my router' home gateway page. Any suggestions would be great, thanks!!

  • Sounds like the problem is with your router, that does not forward port 80 to your webserver. DNS & Apache confs look right, no need for modifications to your /etc/hosts. – SYN Feb 19 '17 at 12:00
  • 1
    Note that if your client is located within your routers' LAN segment, then reflect-NAT-ing troubles are likely, ... We'ld need to know more about your network setup and router device. – SYN Feb 19 '17 at 12:02
  • Hi SYN, you made my day, yes the client is within the same LAN segment, I have just tried my mobile network to test the page and it did respond the correct page, So does that mean I cannot use a client in the same Lan? – wesley Wang Feb 19 '17 at 12:16
  • Ahhhh! classic. At that point, either you can define a NAT rule for your LAN segment (translate private client IP with router private IP, reaching your service, so that TCP handshake can be established - unless with OpenBSD/Linux and root access, unlikely, ...). Or you can look into split-horizon DNS – SYN Feb 19 '17 at 12:20
  • Yeah, it took me hours trying to find the problem, this is very helpful. I should have tried that earlier :) Thanks – wesley Wang Feb 19 '17 at 12:27

Posting a reply, as my comment nailed it: when configuring some NAT on the WAN NIC of your router, then trying to reach your service from a LAN network of your router, a classic issue is related to failing TCP handshake.

On paper, your LAN client wants to connect to a public IP. At which point, either your router doesn't have a NAT rule for your LAN segment, or your router does translate your public IP to the corresponding private IP and then, the service behind your private IP tries to reply directly to your clients' private IP, breaking TCP handshake.

On OpenBSD, I would recommend using relayd on your loopback, and divert traffic to your public IPs (regardless of inbound interface) to this relay. I'm not much familiar with Linux-based routers, I suspect something similar is doable (with haproxy at least).

Now assuming you're on some ISP-provided device, you would have more chances looking into split-horizon DNS - or lying DNS, a cache that would force resolution for some records of yours, like unbound, ...

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.