Networking Forums

Networking Forums > Computer Networking > Linux Networking > iptables REDIRECT original destination-ip

Reply
Thread Tools Display Modes

iptables REDIRECT original destination-ip

 
 
bubzilla
Guest
Posts: n/a

 
      10-17-2006, 04:17 PM
hi

if i use ip_forward on a proxy and:
iptables -t nat -A PREROUTING -p tcp --dport 554 -j REDIRECT --to-port
9999
to catch RTSP-Packets and pass them to the 9999 port of the proxy, how
can i get the original destination-ip.

thx

 
Reply With Quote
 
 
 
 
Pascal Hambourg
Guest
Posts: n/a

 
      10-17-2006, 06:42 PM
Hello,

bubzilla a écrit :
>
> if i use ip_forward on a proxy and:
> iptables -t nat -A PREROUTING -p tcp --dport 554 -j REDIRECT --to-port
> 9999
> to catch RTSP-Packets and pass them to the 9999 port of the proxy, how
> can i get the original destination-ip.


Read the SO_ORIGINAL_DST option of the TCP socket.
Or look up the connection tracking table in /proc/net/ip_conntrack.
 
Reply With Quote
 
bubzilla
Guest
Posts: n/a

 
      10-18-2006, 08:20 AM
thankx

where is SO_ORIGINAL_DST defined , which header ???

 
Reply With Quote
 
bubzilla
Guest
Posts: n/a

 
      10-18-2006, 10:31 AM

bubzilla wrote:
> thankx
>
> where is SO_ORIGINAL_DST defined , which header ???


struct sockaddr_in addr;
bzero((char *) &addr, sizeof(addr));
addr.sin_family = AF_NET;
socklen_t addr_sr = sizeof(addr);

getsockopt(fd, SOL_IP, SO_ORIGINAL_DST, &addr, &addr_sz );

 
Reply With Quote
 
bubzilla
Guest
Posts: n/a

 
      10-18-2006, 10:45 AM
and of course:

#include <linux/netfilter_ipv4.h>

 
Reply With Quote
 
 
 
Reply

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
(iptables) connlimit per destination IP equivalent dzikus Linux Networking 1 04-07-2006 11:23 PM
iptables? redirect? M3ntos Linux Networking 3 05-20-2005 08:16 AM
iptables: destination nat onto same network Chris Lutka Linux Networking 3 03-19-2005 01:35 AM
IPTABLES: -d (destination)=Internet AcCeSsDeNiEd Linux Networking 2 10-02-2004 11:36 AM
Iptables SSL redirect Fritz Bayer Linux Networking 6 07-20-2004 06:08 AM



1 2 3 4 5 6 7 8 9 10 11