Linux Mastering Development

Implementing a transparent proxy with multiple interfaces using iptables

I am trying to connect a public ip (a vps) to a server running inside virtualbox via zerotier network (to avoid port forwarding).

Public VPS setup:

The public IP is a failover ip on a server with interface eth0:1 and ip
The zerotier interface is ztc3q7oq2j with ip

Virtualbox VPS setup:

The zerotier interface is ztc3q7oq2j with ip

Is there a way to implement a transparent proxy so that when a request is made to the public IP it is forwarded through the zerotier network and back?

I tried adapting answers from this question and this tutorial but i can’t get it working. I also want this to apply for all ports. Both servers can ping each other on the zerotier network. This is as far as I got.

iptables -t nat -A PREROUTING -i eth0:1 -j DNAT --to
iptables -A FORWARD -d -i eth0:1 -o ztc3q7oq2j -j ACCEPT
iptables -t nat -A POSTROUTING -o ztc3q7oq2j -d -j SNAT --to

Don’t recommend me other means of proxying the connection, I am trying to figure it out with iptables for educational purposes. 😀

Leave a Reply

Your email address will not be published. Required fields are marked *