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 07-14-2003, 01:42 PM   #1
yetalu
LQ Newbie
 
Registered: Jun 2003
Distribution: Redhat / Solaris 2.6, 7, 8,9
Posts: 10

Rep: Reputation: 0
How can I do simple port forwarding on RH9?


Machine A is the internet gateway (1 pub IP and 1 private IP) and i am running iptable on it now and it is working ok. I want all internet visit to machine A port 80 would automatically forward to machine B with private IP (it would be a web server). so... what should i do ? please help, many thanks~~
 
Old 07-14-2003, 01:49 PM   #2
hakcenter
Member
 
Registered: Apr 2003
Location: Not to far from the computer screen
Distribution: RedHat 9.0
Posts: 324

Rep: Reputation: 30
iptables -t nat -A PREROUTING -j DNAT -s ! LAN --dport 80 --to VIRTUALHOST

where lan is your local area network ip subnet
ex:
machine ips like 192.168.1.13 etc
LAN would be, 192.168.1.0/255.255.255.0
machine ips like 10.1.0.116 etc
LAN would be, 10.1.0.0/255.0.0.0

and VIRTUALHOST is the ip:80 of the virtual host
ex:
192.168.1.116:80
 
Old 07-14-2003, 02:01 PM   #3
yetalu
LQ Newbie
 
Registered: Jun 2003
Distribution: Redhat / Solaris 2.6, 7, 8,9
Posts: 10

Original Poster
Rep: Reputation: 0
hi hakcenter and all, sorry, i forget to tell that the pub IP is dynamic, so......... anythings i should do it again? thanks....
 
Old 07-14-2003, 02:08 PM   #4
hakcenter
Member
 
Registered: Apr 2003
Location: Not to far from the computer screen
Distribution: RedHat 9.0
Posts: 324

Rep: Reputation: 30
actually no, i wrote that to support dhcp wan.

it preroutes anyone that is not on your subnet to that ip
 
Old 07-14-2003, 07:44 PM   #5
wdingus
Member
 
Registered: Aug 2001
Location: Kingsport, TN
Distribution: RHEL & FC
Posts: 267

Rep: Reputation: 30
Something similar to this I've never been able to figure out is how to do this without NAT. More precisely how to re-direct a port to another machine in the same subnet.

For instance all access to port 3306(mysql) on 204.204.204.204 redirected to port 3307 on 204.204.204.205 or something like that. I can never seem to get this to work with iptables but can get more straightforward things like your example to work. Any ideas or suggestions?
 
  


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
iptables on router: simple port forwarding not working hamish Linux - Networking 1 10-27-2005 06:06 AM
Simple enough...iptables..port forwarding pembo13 Linux - Networking 4 07-19-2003 02:08 AM
port forwarding and packet forwarding syrtsardo Linux - Newbie 2 07-03-2003 10:37 AM


All times are GMT -5. The time now is 08:30 AM.

Main Menu
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