DEV Community


Posted on

Redirect traffic to another IP

Imagine that you have an server Linux at your home eth0(, like a raspberry pi, and this machine has a another ethernet card as vpn like wg0(

When you online at vpn the other host can research you Linux server(172.14.11..), but can't access any device on network 192.168.0.. and you would like to share a security camera for example.

What you can do is make a iptables rules on your server to forward the requisition on a por 6666 to internal ip (camera ip)

forward 6666 requests packets to camera
iptables -t nat -A PREROUTING -p tcp -i wg0 --dport 6666 -j DNAT --to-destination
iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 666 -j DNAT --to-destination
iptables -A FORWARD -p udp -d --dport 554 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A POSTROUTING -p tcp -d --dport 554 -j SNAT --to-source
Enter fullscreen mode Exit fullscreen mode

From vpn computer will be able to access where in really is accessing the

Top comments (0)