To forward traffic received on port 27017 from server to 10.10.10.10, you'll need to set up the following iptables rules on the server:
sudo sysctl -w net.ipv4.ip_forward=1
echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.conf
sudo iptables -t nat -A PREROUTING -p tcp --dport 27017 -j DNAT --to-destination 10.10.10.10:27017
sudo iptables -t nat -A POSTROUTING -j MASQUERADE
sudo iptables -A FORWARD -p tcp -d 10.10.10.10 --dport 27017 -j ACCEPT
To make these rules persistent across reboots, save them with:
sudo apt-get install iptables-persistent
sudo netfilter-persistent save
sudo service iptables save
No hay comentarios:
Publicar un comentario