Skip to main content
added 332 characters in body
Source Link
Hauke Laging
  • 94.8k
  • 21
  • 132
  • 185

Routing is about "where (and if) to send to". That's not limited to selecting a NIC. In your case routing is very simple though.

You need masquerading in its most simple form (all commands on host A):

iptables -t nat -I POSTROUTING -s $host_b_ip192.168.22.234 -j MASQUERADE 

And maybe (if not yet) you need allow forwarding:

iptables -I FORWARD 1 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT iptables -I FORWARD 2 -s $host_b_ip192.168.22.234 -j ACCEPT 

HostAssuming host A is configured as the default gateway for Host B.

Edit 1:

After a chat discussion the situation has become clearer. In theory configuring the default gateway on B should have been enough. But it seems that the gateway (which is not under the control of the questioner) blocks host B. Thus the masquerading solution was necessary.

Routing is about "where (and if) to send to". That's not limited to selecting a NIC. In your case routing is very simple though.

You need masquerading in its most simple form:

iptables -t nat -I POSTROUTING -s $host_b_ip -j MASQUERADE 

And maybe (if not yet) you need allow forwarding:

iptables -I FORWARD 1 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT iptables -I FORWARD 2 -s $host_b_ip -j ACCEPT 

Host A is configured as the default gateway for Host B.

Routing is about "where (and if) to send to". That's not limited to selecting a NIC. In your case routing is very simple though.

You need masquerading in its most simple form (all commands on host A):

iptables -t nat -I POSTROUTING -s 192.168.22.234 -j MASQUERADE 

And maybe (if not yet) you need allow forwarding:

iptables -I FORWARD 1 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT iptables -I FORWARD 2 -s 192.168.22.234 -j ACCEPT 

Assuming host A is configured as the default gateway for Host B.

Edit 1:

After a chat discussion the situation has become clearer. In theory configuring the default gateway on B should have been enough. But it seems that the gateway (which is not under the control of the questioner) blocks host B. Thus the masquerading solution was necessary.

Source Link
Hauke Laging
  • 94.8k
  • 21
  • 132
  • 185

Routing is about "where (and if) to send to". That's not limited to selecting a NIC. In your case routing is very simple though.

You need masquerading in its most simple form:

iptables -t nat -I POSTROUTING -s $host_b_ip -j MASQUERADE 

And maybe (if not yet) you need allow forwarding:

iptables -I FORWARD 1 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT iptables -I FORWARD 2 -s $host_b_ip -j ACCEPT 

Host A is configured as the default gateway for Host B.