Linux Networking 101 : Connecting two machines through a Linux router.
We have the below scenario for connecting two machines via a router:
First we enable the "eth1" interface:
Configuration of Host B interface:
We then connect the interface "eth0" of the Host B to the "eth1" interface of the Linux router.
Configuration of Host B interface:
We enable the "eth0" interface of the Host B as below:
Then we give it an IP address:
We then add a default route on Host B, so the packet on Host B would know where to "go" when they leave the local subnet:
Enable routing on Linux router:
To enable our Linux router machine to act as a router, we need to set up the IP forwarding as shown in the below command:
Then we run the below command so that the changes would persist after booting the machine:
Configuration of the interface on Host A:
We start by enabling the interface "eth0":
Then we give it an IP address:
We then add a default route on Host A using the below command:
The default route is used, when no specific route is set for a given IP address destination.
Comments