OpenVZ Forum


Home » General » Support » how to redirect vps port to host
how to redirect vps port to host [message #611] Tue, 27 December 2005 08:39 Go to next message
peian is currently offline  peian
Messages: 2
Registered: December 2005
Junior Member
I want to redirect traffic towards a vps port to a host port.
e.g. 192.168.1.3 is host IP, 192.168.1.13 is a VPS ip.
I want to redirect 192.168.1.13:3456 to 192.168.1.3:80

How do I do it?

This doesn't work:
iptables -t nat -A PREROUTING -p tcp -d 192.168.1.13 --dport 3456 -j DNAT --to 192.168.1.3:80


Thanks a lot.

[Updated on: Tue, 27 December 2005 15:13]

Report message to a moderator

Re: how to redirect vps port to host [message #612 is a reply to message #611] Tue, 27 December 2005 13:05 Go to previous messageGo to next message
dim is currently offline  dim
Messages: 344
Registered: August 2005
Senior Member
Do you enable iptable_nat module for your VPS?
Do you have iptable_nat module loaded before VPS start?


http://static.openvz.org/openvz_userbar_en.gif
Re: how to redirect vps port to host [message #613 is a reply to message #611] Tue, 27 December 2005 14:33 Go to previous messageGo to next message
scythe is currently offline  scythe
Messages: 22
Registered: December 2005
Location: Hungary
Junior Member
Hi

I have the same problem (except Im trying to forward a port inside the vps from the host and not outside as peian above - port 8080 of host into port 80 of VPS), and I have iptable_nat loaded before vps start, as well as conntrack enabled on ve0. Probably i (we) are missing some module/setting for iptables, but i cant find which one. My config:

192.168.8.128 is the host address (running in vmware, but that shouldnt count)
10.1.1.1 is the vps address - i can ssh into the vps from the host

# iptables -t nat -A PREROUTING -p tcp -d 192.168.8.128 --dport 8080 -j DNAT --to 10.1.1.1:80

after adding this line to iptables, i just get a connection refused on 192.168.8.128:8080. All rules are set to accept, i dont use any other iptables settings currently.

Thanks for any help!

(Edit: typos)

[Updated on: Tue, 27 December 2005 14:38]

Report message to a moderator

Re: how to redirect vps port to host [message #614 is a reply to message #613] Tue, 27 December 2005 15:06 Go to previous messageGo to next message
dim is currently offline  dim
Messages: 344
Registered: August 2005
Senior Member
Your case is known issue - see http://openvz.org/documentation/faq/en#14 for details.


http://static.openvz.org/openvz_userbar_en.gif
Re: how to redirect vps port to host [message #615 is a reply to message #612] Tue, 27 December 2005 15:09 Go to previous message
peian is currently offline  peian
Messages: 2
Registered: December 2005
Junior Member
dim wrote on Tue, 27 December 2005 07:05

Do you enable iptable_nat module for your VPS?
Do you have iptable_nat module loaded before VPS start?



No, it's not compiled, as "iptables -nvL -t nat" showed it.
But I thought it's host problem. The traffic supposed to be intercepted by host, and not seen at all by VPS. So it doesn't matter if iptables nat is enabled or not in VPS, right?

"iptables -nvL -t nat" in host does work. It report 0 pkts and 0 bytes for prerouting chain.

Is there additional rule/chain/target I should add to iptables?

Thanks
Previous Topic: Problem installing kernel
Next Topic: I need help and will PAID $$$ for it
Goto Forum:
  


Current Time: Sat Aug 03 22:23:31 GMT 2024

Total time taken to generate the page: 0.02580 seconds