0

I am new to netplan and advanced linux networking in general so I am hoping someone might be able to help me figure out my problem.

I have two machines, an unraid nas and an ubuntu 18.04 server. Each machine has two ethernet network interfaces. I'm trying to use one interface on each machine to connect them to my LAN while using the other interfaces to connect them directly to each other with a crossover cable.

My machines are setup as follows

Unraid

  • eth0 > LAN, DHCP, 192.168.1.x
  • eth1 > Direct, Static, 10.0.0.1/24

Ubuntu

  • enp2s0 > LAN , DHCP , 192.168.1.x
  • enp3s5 > Direct, Static, 10.0.0.2/24

I managed to get the machine to connect to each other using this netplan config on the Ubuntu server.

network:
  version: 2
  renderer: networkd
  ethernets:
    enp2s0:
      dhcp4: yes
    enp3s5:
      dhcp4: no
      addresses:
        - 10.0.0.2/24
      gateway4: 10.0.0.2

This seemed to work until I tried to ssh into my ubuntu server from the internet. I have port forwarding set up on my LAN's router and have been successfully using this setup for months. With this now failing, I went and did some research and ran route -n on my ubuntu server which gave me the following output.

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use 
Iface
0.0.0.0         10.0.0.2        0.0.0.0         UG    0      0        0 enp3s5
0.0.0.0         192.168.1.1     0.0.0.0         UG    100    0        0 enp2s0
10.0.0.0        0.0.0.0         255.255.255.0   U     0      0        0 enp3s5
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 enp2s0
192.168.1.1     0.0.0.0         255.255.255.255 UH    100    0        0 enp2s0

From what little I've learned, it seems my machine will use the gateway 10.0.0.2 to try and answer requests outside the LAN's subnet because it has a lower metric value. This would explain why I could not ssh into this machine from outside my network as only my LAN has internet access.

My first thought is to define a larger metric value to enp3s5. Is this the right way to do this? Or do I have this wrong?

Any help would be really appreciated.

0

What do you mean by "connect from outside my LAN"?

You can not access 192.168.x.x or 10.x.x.x or any other private IPv4 from outside unless you have a gateway with a forward rule.

  • I mean from the internet using port forwarding through my router which in on the LAN. I will update my question. – GMihovics Jan 11 at 3:06
  • You should use the router as default gateway on your ubuntu server and configure 10.10.0.x as 2nd connection. Incoming pakets will be routed from your router to 192.168.1..x, but outgoing pakets can not reach the router via 10.10.0.x. – Thomas Aichinger Jan 12 at 8:29
  • That was what I was thinking at one point but then I thought it was weird to define the gateway for the interface when DHCP should be doing that. I'll give it a try and see what happens. – GMihovics Jan 12 at 18:44

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.