Hello,
While I can see example of using udp on tproxy2 onto the redirect-udp-recv.c
file, I can't find equivalent on tproxy4.
For getting the original destination IP, I just use setsockopt IP_PKTINFO:
setsockopt(sd, SOL_IP, IP_PKTINFO , &flags, sizeof(flags));
But I don't know how to get the original destination port:
a) I manually defined IP_RECVORIGADDRS to be 11273 as I find on tproxy2:
setsockopt(sd, SOL_IP, IP_RECVORIGADDRS , &flags, sizeof(flags));
but the setsockopt failed.
b) the getsockname give me the server listening port.
Here are my iptables\ip route redirection lines:
${iptables} -t mangle -N DIVERT
${iptables} -t mangle -A PREROUTING -p udp -m socket -j DIVERT
${iptables} -t mangle -A DIVERT -j MARK --set-mark 1
${iptables} -t mangle -A DIVERT -j ACCEPT
${iptables} -t mangle -A PREROUTING -p udp --dport 1500 -j TPROXY
--tproxy-mark 1 --on-port 3127
ip rule add fwmark 1 lookup 100
ip route add local 0.0.0.0/0 dev lo table 100
What is missed?
Best,
Moshe