Use a gateway from another NIC

I have a machine (machin-A (Ubuntu 18.04)) with two NIC's. one is eth0 and the other eth1. eth0 connected to the company subnet. eth1 connected to a second Linux machine (Machine-B) . both physical machines.

i need to traffic information from machine-B to machine-C that is also connected to company subnet

How can i do that?


Solution 1:

Simplest is to set up NAT on machine A, but that assumes that C doesn't need to start a connection to B. This means that any traffic from B will look like it's coming from A to any machine on the company network.

To do this you need to allow IPv4 routing (net.ipv4_ip_forwarding = 1) and setup MASQUADE with iptables.

The other option is to bridge eth0/eth1 then B will appear on the same network as both A & C.