Adding the LAN IP address to the wireguard wg0 address?

Ubuntu Version:24.04 LTS

Desktop Environment (if applicable):Cosmic

Problem Description:I am trying to connect the “LAN” to the VPN.

Relevant System Information:
I have two ethernet ports. One is WAN and the other is intended to be “LAN”.

Screenshots or Error Messages:I am not setting up my “ip route” commands correctly.

What I’ve Tried:I have tried several times to use “ip route”.

Before Posting:I have checked various websites for information.

I would like to connect a single ethernet port “LAN” at “192.168.2.1” to my wireguard VPN. I would like the LAN to be protected by the VPN. I read that “ip route” would be good for this. “192.168.2.1” pings fine, but can change if there is a better recommendation. “10.164.0.48” for the VPN also pings fine. I would like to do all of this in networkd and I have Pop!_OS (Ubuntu) 24.04. I have two ethernet ports on my PC with one being the WAN and the other intended to be LAN. The WAN part is working fine. The “LAN” may not be configured correctly.

$ networkctl
IDX LINK        TYPE     OPERATIONAL SETUP
  1 lo          loopback carrier     unmanaged
  2 enp2s0f0    ether    routable    configured
  3 enp1s0      ether    routable    configured
  4 wlo1        wlan     off         unmanaged
 25 wg0-mullvad none     routable    unmanaged
$ ip route
default via 192.168.225.1 dev enp2s0f0 proto dhcp src 192.168.225.154 metric 1024
10.64.0.1 dev wg0-mullvad proto static
45.134.142.219 dev wg0-mullvad proto static
192.168.2.0/24 dev enp1s0 proto kernel scope link src 192.168.2.1
192.168.225.0/24 dev enp2s0f0 proto kernel scope link src 192.168.225.154 metric 1024
192.168.225.1 dev enp2s0f0 proto dhcp scope link src 192.168.225.154 metric 1024
$ ifconfig
enp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.1  netmask 255.255.255.0  broadcast 192.168.2.255
        inet6 fe80::b696:91ff:fe6a:40ce  prefixlen 64  scopeid 0x20<link>
        ether b4:96:91:6a:40:ce  txqueuelen 1000  (Ethernet)
        RX packets 47  bytes 15534 (15.5 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 204  bytes 14230 (14.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xfe600000-fe6fffff

enp2s0f0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.225.154  netmask 255.255.255.0  broadcast 192.168.225.255
        inet6 fe80::863a:5bff:fe14:bc48  prefixlen 64  scopeid 0x20<link>
        ether 84:3a:5b:14:bc:48  txqueuelen 1000  (Ethernet)
        RX packets 253934  bytes 365107065 (365.1 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 131136  bytes 186797131 (186.7 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 23120  bytes 2021781 (2.0 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 23120  bytes 2021781 (2.0 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wg0-mullvad: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1380
        inet 10.164.0.48  netmask 255.255.255.255  destination 10.164.0.48
        inet6 fe80::d679:9be4:6fbf:2d6c  prefixlen 64  scopeid 0x20<link>
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 500  (UNSPEC)
        RX packets 7560  bytes 6299735 (6.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6083  bytes 1289414 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

(WAN) /etc/systemd/network/20-enp2s0f0.network

[Match]
Name=enp2s0f0
[Network]
DHCP=yes

(LAN) /etc/systemd/network/30-enp1s0.network

[Match]
Name=enp1s0
[Network]
Address=192.168.2.1/24

Is there a simple way of doing this with “ip route”? I have tried, but am not getting the command correct. Thanks for any help.

How about using the proper Ubuntu network stack as described here (there are more examples for wireguard setups on that official Ubuntu networking doc):

https://netplan.readthedocs.io/en/stable/examples/#how-to-connect-your-home-computer-to-a-cloud-instance-with-a-wireguard-vpn

Firstly, welcome to Ubuntu Discourse :slight_smile:

We are always happy to try and help when we can.

However, be aware that the support here is for official Ubuntu versions and flavours only.

While it may share some similarities with Ubuntu, Pop_OS! has its own configuations and setup.

Thanks

3 Likes

This topic was automatically closed after 30 days. New replies are no longer allowed.