N
N
NkDev2018-10-09 11:24:06
linux
NkDev, 2018-10-09 11:24:06

How to make access to external ip from local network?

I have a DIR-615 router at home connected via cable to the Internet, with a static ip. A desktop computer with ubuntu 16.04 is connected to the Internet via wi-fi through this router. A web server with a website (test.ru) is deployed on the computer. When I access the site from the external Internet, everything works - the site opens. When I access the site from the same local network (via the same wifi connection) the site doesn't load.
I found a solution to the problem on the Internet - nat loopback. My router does not have such a function, so they suggest either flashing the router to an alternative firmware, or setting up loopback via iptables. I connected to via telnet to the router and entered the commands:

iptables -t nat -A PREROUTING -d <мой внешний ip> -m tcp -p tcp --dport 80 -j DNAT --to-destination 192.168.0.26:80

and
iptables -t nat -A POSTROUTING -d 192.168.0.26 -p tcp --dport 80 -j SNAT --to-source <мой внешний ip>

However, this did not help.
Here is the conclusion iptables -t nat -L -n -v:
5bbce9bbecd5c896873194.jpeg
Tell me what I did wrong? How to solve the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
beerchaser, 2018-10-10
@NkDev

It's easier to steer through splitdns. Those. make it so that for local machines on test.ru DNS gives a local address. To do this, you need to either train Dir 615 for this (if it is specified as a DNS server) or raise a DNS server on a computer with a web server, register the test.ru zone on it with local addresses and specify it as the first one when distributing via DHCP (if it is used) or in the network connection settings of computers. The computer hosting the web server must also have a local DNS address. If there are not many computers, you can write the local test.ru to them in hosts.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question