nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

forwarding requests to another ip using IPTABLES

This is a discussion on forwarding requests to another ip using IPTABLES within the Linux software forums, part of the Linux Getting Started category; Dear all, I am trying to forward packets coming to one ip address(say 192.168.1.222 port 4080) to another ip address ...


Go Back   nixCraft Linux Forum > Linux Getting Started > Linux software

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 03-16-2005, 02:03 PM
ranjanjajodia
Guest
 
Posts: n/a
Default forwarding requests to another ip using IPTABLES

Dear all,
I am trying to forward packets coming to one ip address(say 192.168.1.222 port 4080) to another ip address (say 192.168.1.11.

I tried the following rule:

iptables -t nat -A PREROUTING -p tcp -d 192.168.1.222 --dport 4080 -j DNAT --to-destination 192.168.1.118

But it did not work. I also observed that,

iptables -t nat -A PREROUTING -p tcp -d 192.168.1.118 --dport 4080 -j DNAT --to-destination 192.168.1.118:4088

works, i.e, port redirection works.

I tried out google and also read a couple of tutorials but unfortuately I am still unable to find the problem.

I am using Red Hat 8 on both the computers.

Can any one point me to the right direction?

Thanks,
Ranjan
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-16-2005, 07:25 PM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
My distro: Debian GNU/Linux
Posts: 482
Rep Power: 5
monk will become famous soon enough monk will become famous soon enough
Default

Code:
iptables -t nat -A PREROUTING -p tcp -d 192.168.1.222 --dport 4080 -j DNAT --to-destination 192.168.1.118
But it did not work. I also observed that,

Because you did not specified the port in --to-destination IP:PORT. You need to give port also it can not guess it

Code:
iptables -t nat -A PREROUTING -p tcp -d 192.168.1.118 --dport 4080 -j DNAT --to-destination 192.168.1.118:4088
works, i.e, port redirection works.

Answer it as above for second

This port redirection (iptables based) will only works if the destination is in the same network on locally attached interface. If you need to forward it to other network then you need tiny utility called rinetd which is a TCP port redirector. See http://www.boutell.com/rinetd/ for more and to download it.
Reply With Quote
  #3 (permalink)  
Old 03-17-2005, 08:34 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,061
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

rinetd is my personal choice
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Restricting Port forwarding in SSH server ricc Networking, Firewalls and Security 2 08-07-2008 09:14 PM
Port forwarding satimis Networking, Firewalls and Security 0 02-02-2008 08:45 AM
Iptables nixsen CentOS / RHEL / Fedora 2 11-29-2007 04:01 PM
iptables help vitaminme Networking, Firewalls and Security 1 09-04-2007 03:42 AM
IPTABLES help vasanth Linux software 1 03-09-2005 10:15 AM


All times are GMT +5.5. The time now is 01:42 AM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36