Would you please help me . I have a 2 vps (Ubuntu) I want to forward all traffic from one vps(1.1.1.1) to another (2.2.2.2) vps except ssh port on A vps(1.1.1.1) A server is 1.1.1.1 B server is 2.2.2.2
1st try:
sysctl net.ipv4.ip_forward=1
iptables -t nat -A PREROUTING -i eth0 -d 1.1.1.1 -j DNAT --to 2.2.2.2
iptables -A FORWARD -i eth0 -d 1.1.1.1 -p tcp --dport 22 -j REJECT
iptables -A FORWARD -i eth0 -d 2.2.2 -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
2nd try
sysctl net.ipv4.ip_forward=1
iptables -t nat -A PREROUTING -j DNAT --to-destination 1.1.1.1
iptables -t nat -A PREROUTING -j DNAT --to-destination 2.2.2.2
iptables -t nat -A POSTROUTING -j SNAT
Both failed