<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.18.3">
</HEAD>
<BODY>
Hello,<BR>
<BR>
While I can see example of using udp on tproxy2 onto the redirect-udp-recv.c<BR>
file, I can't find equivalent on tproxy4.<BR>
<BR>
For getting the original destination IP, I just use setsockopt IP_PKTINFO:<BR>
setsockopt(sd, SOL_IP, IP_PKTINFO , &amp;flags, sizeof(flags));<BR>
<BR>
But I don't know how to get the original destination port:<BR>
<BR>
a) I manually defined IP_RECVORIGADDRS&nbsp; to be 11273 as I find on tproxy2:<BR>
setsockopt(sd, SOL_IP, IP_RECVORIGADDRS , &amp;flags, sizeof(flags));<BR>
but the setsockopt failed.<BR>
<BR>
b) the getsockname give me the server listening port.<BR>
<BR>
<BR>
Here are my iptables\ip route redirection lines:<BR>
${iptables} -t mangle -N DIVERT<BR>
${iptables} -t mangle -A PREROUTING -p udp -m socket -j DIVERT<BR>
${iptables} -t mangle -A DIVERT -j MARK --set-mark 1<BR>
${iptables} -t mangle -A DIVERT -j ACCEPT<BR>
${iptables} -t mangle -A PREROUTING -p udp --dport 1500 -j TPROXY<BR>
--tproxy-mark 1 --on-port 3127<BR>
<BR>
ip rule add fwmark 1 lookup 100<BR>
ip route add local 0.0.0.0/0 dev lo table 100<BR>
<BR>
<BR>
What is missed?<BR>
<BR>
Best,<BR>
Moshe<BR>
<BR>
<BR>
</BODY>
</HTML>