Score:0

Iptables Traffic forward

tv flag

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

us flag
What have you tried? How it failed?
Havard avatar
tv flag
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
us flag
Please add additional information to the question by editing so that it is properly formatted.
Havard avatar
tv flag
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
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.