D
D
diiimonn2015-07-02 18:12:43
System administration
diiimonn, 2015-07-02 18:12:43

iptables rule, what's wrong?

I'm experimenting with routing.
The connection is: my computer -> router -> world.
zz.zz.zz.zzz - static address on the router, the address of my computer in the home network is 192.168.1.100.
I do it like this:

#iptables -t nat -A PREROUTING -p tcp --dport 5656 -j DNAT --to-destination xxx.xx.xx.xxx:80

xxx.xx.xx.xxx - there is just such a site address.
I expect that if I access zz.zz.zz.zzz:5656 from the browser, then the site will open for me. But even does not open and everything freezes in endless waiting.
There are no more additional rules in iptables or routing tables. Ports 80 and 5656 are forwarded on the router.
How to make it work?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
mureevms, 2015-07-02
@diiimonn

So you're doing all this on a local Linux machine? And redirect local requests through the router to yourself using NAT on the same machine? Monsieur knows a lot :)
It seemed to me that all three who answered before me thought that Linux = router in your description. That's what I thought at first.
In general, do not suffer from garbage, raise a virtual machine, and you will NAT your machine on it.

3
3vi1_0n3, 2015-07-02
@3vi1_0n3

Forgotten Post-Rooting

iptables -t nat -A PREROUTING -d <адрес-роутера-в-локалке> -p tcp -m tcp --dport 5656 -j DNAT --to-destination xxx.xx.xx.xxx:80
iptables -t nat -A POSTROUTING -d xxx.xx.xx.xxx -p tcp -m tcp --dport 5656 -j SNAT --to-source <адрес-машины-в-локалке>

A
Andrey Burov, 2015-07-02
@BuriK666

show all iptables -v -n -t nat -L PREROUTING
Order of rules in iptables matters .

A
Azazel PW, 2015-07-02
@azazelpw

Something like this:
iptables -t nat -A PREROUTING -p tcp -s 192.168.0.2 -d 0.0.0.0/0 --dport 5656 -j DNAT --to-destination xxx.xx.xx.xxx:80
I think it's clear that 192.168.0.2 is the local address from which the request is coming.
corrected a typo

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question