LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-21-2005, 08:53 AM   #1
phatboyz
Member
 
Registered: Feb 2004
Location: Mooresville NC
Distribution: CentOS 4,Free BSD,
Posts: 358

Rep: Reputation: 30
Port forwarding


I have no clue as to what iptables command to run so I need some help. I am connecting to my network though a VPN client. I need to have my Cent OS4 box forward a connection. The reason for this is my mail server is here and then to login to my As400 I have to shutdown the VPN and bring it back up on a different site. I was wondering if I could just connect to my local work and have my computer inside route me accross the VPN. The trick is I have to connect on one port and forward to another.

Server address aab.bbb.ccd.12 Port 24 to be forwarded to aab.bbc.dcc.99 Port 23.

Can someone help me do this?
 
Old 11-21-2005, 12:04 PM   #2
Que_273
Member
 
Registered: Nov 2005
Location: South coast
Distribution: Debian /AMD64
Posts: 48

Rep: Reputation: 15
You need an entry like this in your "nat" table
iptables -t nat -A PREROUTING -p tcp -m tcp -s aaa.bbb.ccc.ddd --dport 24 -j DNAT --to-destination uuu.vvv.www.xxx:23

I used this to allow me to ssh into a firewalled computer with one command (instead on logging into one and then into the other)
The only problem is that because my ssh program sees the same ip address being used but with different RSA keys it wants me to check. I probably could get them to use the same key but that might not be good. It might not be a problem for you though.
 
Old 11-21-2005, 03:18 PM   #3
phatboyz
Member
 
Registered: Feb 2004
Location: Mooresville NC
Distribution: CentOS 4,Free BSD,
Posts: 358

Original Poster
Rep: Reputation: 30
Here is what I came up with. Its not passing the connection at all. I don't even see the rule listed.
iptables -t nat -A PREROUTING -p tcp -m tcp -s 10.0.2.22 --dport 24 -j DNAT --to-destination 192.1.1.1:23


iptables --list
Chain INPUT (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- anywhere anywhere

Chain FORWARD (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- anywhere anywhere

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Chain RH-Firewall-1-INPUT (2 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT icmp -- anywhere anywhere icmp any
ACCEPT ipv6-crypt-- anywhere anywhere
ACCEPT ipv6-auth-- anywhere anywhere
ACCEPT udp -- anywhere 224.0.0.251 udp dpt:5353
ACCEPT udp -- anywhere anywhere udp dpt:ipp
ACCEPT all -- anywhere anywhere state RELATED,ESTAB
LISHED
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:h
ttp
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:h
ttps
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:f
tp
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:s
sh
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:s
mtp
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:l
mtp
REJECT all -- anywhere anywhere reject-with icmp-ho
st-prohibited
 
Old 11-21-2005, 03:21 PM   #4
Que_273
Member
 
Registered: Nov 2005
Location: South coast
Distribution: Debian /AMD64
Posts: 48

Rep: Reputation: 15
iptables --list (also iptables -L) will list only the filter table
to see the nat table use iptables -t nat --list (or iptables -t nat -L)
 
Old 11-21-2005, 03:36 PM   #5
phatboyz
Member
 
Registered: Feb 2004
Location: Mooresville NC
Distribution: CentOS 4,Free BSD,
Posts: 358

Original Poster
Rep: Reputation: 30
Does this look Right?

[root@gridgenotes12 ~]# iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
DNAT tcp -- 10.0.2.22 anywhere tcp dpt:449 to:192.1.1.1:449
DNAT tcp -- 10.0.2.22 anywhere tcp dpt:8476 to:192.1.1.1:8476
DNAT tcp -- 10.0.2.22 anywhere tcp dpt:8470 to:192.1.1.1:8470
DNAT tcp -- 10.0.2.22 anywhere tcp dpt:lmtp to:192.1.1.1:23

Chain POSTROUTING (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
 
  


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
IPCHAINS port forwarding and IPTABLES port forwarding ediestajr Linux - Networking 26 01-14-2007 07:35 PM
Simple Port Forwarding Firewall - not forwarding MadTurki Linux - Security 14 04-09-2006 12:08 PM
Port 80 forwarding to port 22 with iptables zahoo Linux - Networking 3 02-22-2005 07:22 AM
Port Forwarding sfichera Linux - Networking 2 07-22-2004 12:28 PM
port forwarding and packet forwarding syrtsardo Linux - Newbie 2 07-03-2003 10:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:55 AM.

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
Open Source Consulting | Domain Registration