I tried googling for a while, but I can't put my problem to a good search query so I can't find an answer for what I'm trying to do.

Here we go: I have 3 PCs that I'm trying to connect with my own subnet. One of them is already connected to an outside network and has internet connection. Here's my configuration:

  • PC1: has two NICs,
    • eth0 has the DHCP IP, the gateway is, and DNS is set automatically to,,, This is the outside network.
    • eth1 has the static IP, I set the gateway to (the IP of eth0), I didn't set DNS.
  • PC2: has the static IP Gateway is No DNS.
  • PC3: has the static IP Gateway is No DNS.

Now the two networks work beautifully. I can ssh, ping, and whatever else I need to do except for internet. So my question is the following:

  1. How do I set the gateway on PC1-eth1 so it forwards from the inner network to the outer one? my current solution doesn't work.
  2. How do I set the DNS for PC1-eth1, PC2, and PC3? do I simply set it to and the gateway will handle the DNS requests? Or do I have to setup a DNS server?!

All three machines are using Ubuntu 18.04.


After a lot of tiring search. I found this: https://help.ubuntu.com/community/Internet/ConnectionSharing#Ubuntu_Internet_Gateway_Method_.28iptables.29

Which describes how to do this type of forwarding between different networks through two NICs. Exactly what I'm looking for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.