Skip to contentSkip to conversation

iptables help

DISCUSSION Wei Ming Long 3 participants 3 messages Nov 4, 2004 netfilter

lore
Share & tools
lore
#0 lore raw

Hi everone,

I have a setup as shown below:

                   VNC Server 192.168.1.4
                          |
                          | --------> ssh tunnel on port 5800
                          |
                eth1= 192.168.1.2
                          |
                Linux Gateway
                          |
                 eth0=192.168.33.167
                          |
                          |
                 WindowsXP 192.168.33.164 

Requirement: To be able to access the VNC Server behind the Linux gateway using the web browser on port 5800 tunneled through ssh.

I created a ssh tunnel between the VNC Server(192.168.1.4) & the Linux Gateway(192.168.1.2) for port 5800 and the following iptables command in Gateway:

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to 192.168.1.2:5800

When I type in http://192.168.33.167 in the browser on the WindowsXP machine, Iwas expecting that the http request on port 80 would be redirected to port 5800 & go through the tunnel & reach the VNC Server.

But it doesn't work, what is wrong? can someone please help me with this?

Best regards
Matthew

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This email is confidential and may be privileged. If you are not the intended recipient, please delete it and notify us immediately. Please do not copy or use it for any purpose, or disclose its contents to any other person. Thank You.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

#1 lore raw
Quoted 25 lines · Wei Ming Long

Hi everone,

I have a setup as shown below:

                   VNC Server 192.168.1.4
                          |
                          | --------> ssh tunnel on port 5800
                          |
                eth1= 192.168.1.2
                          |
                Linux Gateway
                          |
                 eth0=192.168.33.167
                          |
                          |
                 WindowsXP 192.168.33.164 

Requirement: To be able to access the VNC Server behind the Linux gateway using the web browser on port 5800 tunneled through ssh.

I created a ssh tunnel between the VNC Server(192.168.1.4) & the Linux Gateway(192.168.1.2) for port 5800 and the following iptables command in Gateway:

Quoted 8 lines

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to 192.168.1.2:5800

When I type in http://192.168.33.167 in the browser on the WindowsXP machine, Iwas expecting that the http request on port 80 would be redirected to port 5800 & go through the tunnel & reach the VNC Server.

But it doesn't work, what is wrong? can someone please help me with this?

without seeing how your ssh forwarding is setup, no.

-j

--
"Ah! the searing kiss of hot lead; how I missed you! I mean, I think
I'm dying."
--The Simpsons

#2 lore raw
In reply to Wei Ming Long
Quoted 14 lines · Wei Ming Long
                   VNC Server 192.168.1.4
                          |
                          | --------> ssh tunnel on port 5800
                          |
                eth1= 192.168.1.2
                          |
                Linux Gateway
                          |
                 eth0=192.168.33.167
                          |
                          |
                 WindowsXP 192.168.33.164 
Quoted 2 lines

Requirement: To be able to access the VNC Server behind the Linux gateway using the web browser on port 5800 tunneled through ssh.

If the 192.168.33.0/24 network has a valid route for the 192.168.1.0/24 network through the Linux gateway, then you could SSH directly to the VNC server without NAT. On the Windows XP machine you can use plink or putty to make the port mappings, and point the XP web browser to localhost.

Be advised that VNC port 5800 has java stuff only, while I believe that VNC traffic still will transmit on port 5900, so you might need to create an additional SSH tunnel, if you can't use a vncviewer on the XP machine and do with a SSH port link on port 5900.

Quoted 2 lines

I created a ssh tunnel between the VNC Server(192.168.1.4) & the Linux Gateway(192.168.1.2) for port 5800

OK, you can do this if the networks are not routable with each other. For troubleshooting I would get a vncviewer on the XP box, instead of fiddling around with the java stuff. When you can get an ordinary connection with a vncviewer on port 5900, you can try creating another SSH tunnel for port 5800, and see if you can access the java client.

On the linux box, you can run this:
ssh -N -L 5800:localhost:5800 192.168.1.4
ssh -N -L 5900:localhost:5900 192.168.1.4

And then go to http://192.168.33.167:5800 from your XP web browser.

Quoted 2 lines

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to 192.168.1.2:5800

I don't really see the need for NAT here.

.../Bosse

Signature · 2 lines
Bosse Klykken - http://www.klykken.com/~bosse
Keep staring. I might do a trick.