LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 05-06-2010, 10:56 AM   #1
daveginorge
Member
 
Registered: Oct 2006
Location: Porsgrunn, Norway
Distribution: CentOS 5
Posts: 93

Rep: Reputation: 16
IPTABLES PORT TRANSLATION / REDIRECT to a different address


Hi All
CentOS 5.x

We have 5 CentOS servers performing different tasks. We use VNC for all the servers as they are screen mouse and keyboardless. That all works no problem. I need to be able to log into all from remote locations outside the local network, at present I log into the firewall and run VNC from there to access the rest, this makes things a little slow on the screen. I would like to access the servers on separate ports and have the firewall redirect them to port 5900 on the relevant servers

eg.
lan interface eth0
public interface eth1
firewall-box 192.168.1.1
server1 192.168.1.2
How do I get vnc to be redirected to port 5900 on server1 when I type public_address:5901 in the vnc client
I have tried
Code:
iptables -A FORWARD -p tcp -i ethi --dport 5901 -s $192.168.1.2 -j ACCEPT
iptables -t nat -A PREROUTING -i eth1 -p-tcp --dport 5901 -j DNAT --to 192.168.1.2:5900
This does not work. I have googled a whole lot but all examples show redirect to the local machine.

Is this possible.
Thanks in advance
 
Old 05-07-2010, 10:25 AM   #2
imitheos
Member
 
Registered: May 2005
Location: Greece
Posts: 374

Rep: Reputation: 55
Quote:
Originally Posted by daveginorge View Post
no problem. I need to be able to log into all from remote locations outside the local network, at present I log into the firewall and run VNC from there to access the rest, this makes things a little slow on the screen. I would like to access the servers on separate ports and have the firewall redirect them to port 5900 on the relevant servers

eg.
lan interface eth0
public interface eth1
firewall-box 192.168.1.1
server1 192.168.1.2
How do I get vnc to be redirected to port 5900 on server1 when I type public_address:5901 in the vnc client
I have tried
Code:
iptables -A FORWARD -p tcp -i ethi --dport 5901 -s $192.168.1.2 -j ACCEPT
iptables -t nat -A PREROUTING -i eth1 -p-tcp --dport 5901 -j DNAT --to 192.168.1.2:5900
This does not work. I have googled a whole lot but all examples show redirect to the local machine.

Is this possible.
Thanks in advance
Have you tried the following ?
Code:
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 5901 -j DNAT --to-destination 192.168.1.2:5900
iptables -A FORWARD -p tcp --dport 5900 -d 192.168.1.2 -j ACCEPT
 
Old 05-07-2010, 02:59 PM   #3
arenasa
LQ Newbie
 
Registered: Oct 2000
Location: Curaçao
Distribution: Fedora, Centos
Posts: 18

Rep: Reputation: 1
Could be a typo (ethi instead of eth1)... on the first line of your example?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Iptables can't port forward (PAT Port address translation) sfrederiksen Linux - Networking 7 12-20-2011 11:47 AM
Need help implementing Port Address Translation with iptables Ashmatash Linux - Networking 4 02-04-2010 11:11 PM
debian iptables squid - redirect port 80 to port 8080 on another machine nickleus Linux - Networking 1 08-17-2006 01:59 AM
Test if port address translation is working dales79 Linux - Security 1 01-17-2006 08:01 AM


All times are GMT -5. The time now is 10:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration