I am working on setting up some ICS honeypots for research so I need to be able to record the origin IP address of traffic I recieve.
I'm running the servers myself on prem but am behind a CGNAT/Double NAT on a 4G connection. I have set up port forwarding through a Wiregurad VPN tunnel to a Linux VPS to give an external IP address where I can open ports.
This works fine however because of the port forwarding all traffic recieved by the honeypots has the origin IP address of the VPS. As far as I can understand it's not possible to forward it with the origin IP address as there will be issues with the return traffic routing.
My question is what would be a good method to record the origin IP so that it could be matched up with the traffic recieved on the honeypot? I'm planning to capture all traffic at the honeypot, would it be plausible to also capture at the VPS and correlate the two somehow?
Thanks, Dave
Using the answer below here's the steps I took to get this working:
1: Removed the MASQUERADE line above to stop the source IP address being modified.
2: Add the policy based routing to the Honeypot side:
ip -4 route add default dev wg0 table 4242
ip -4 rule add pref 500 from x.x.x.2 lookup 4242
3: Change the AllowedIPs on the Wireguard configuration on the Honeypot side to direct all traffic for external IP addresses back through the tunnel. I used this website to calculate the correct configuration https://www.procustodibus.com/blog/2021/03/wireguard-allowedips-calculator/
One trap to watch out for is to make sure you exclude the IP address for the VPS as otherwise wireguard will try to direct the tunnel setup traffic through the not yet existing tunnel, which goes about as well as you might imagine!
Edit: I've added a diagram to help illustrate things. Both the VPS and the Honeypot host are Ubuntu machines connected directly through the tunnel. How owuld I go about using policy based routing to preserve the source IP address z.z.z.z once it reaches the Honeypot. Let's say y.y.y.y:44444 on the VPS is being forwarded to x.x.x.2:33333.
Current IPTables rules used for forwarding (on VPS):
iptables -I FORWARD -d x.x.x.2 -p tcp --dport 33333 -j ACCEPT
iptables -I FORWARD -s x.x.x.2 -p tcp --sport 33333 -j ACCEPT
iptables -t nat -I PREROUTING -p tcp --dport 44444 -j DNAT --to-destination x.x.x.2:33333
iptables -t nat -I POSTROUTINGq -d x.x.x.2 -o wg0 -j MASQUERADE