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
- eth0 > LAN, DHCP, 192.168.1.x
- eth1 > Direct, Static, 10.0.0.1/24
- 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.