1

I'm trying to convert this ip tunnel creation process:

sudo ip tuntap add tun0 mode tun
sudo ip addr add 192.168.7.2/25 dev tun0
sudo ip link set dev tun0 up
sudo ip addr show tun0

to a netplan configuration, but need to specify more parameters in netplan to cover what seems to be defaults in the ip version.

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: false
      dhcp6: false
      addresses: ["192.168.7.2/25"]
  tunnels: 
    tun0: 
      mode: gre 
      addresses: ["192.168.8.2/25"]
      remote: 192.168.8.100
      local: 192.168.7.2

What is the equivalent netplan mode?

How can I do what I do with ip on the command line with netplan?

See also:

tarabyte
  • 2,585

1 Answers1

2

What is the equivalent netplan mode?

None – your command does not create a tunnel at all. The 'tun' interface it creates is a completely different thing, where the endpoint is a local process rather than a remote host as is the case with tunnels. So it's not about 'ip' having defaults, or anything like that – a 'tun' interface doesn't have those parameters at all.

(tun/tap is named that way because it's meant to be used with software that implements the "tunnel" part; by itself the interface does nothing.)

Netplan does not support creating tun/tap devices, but if you're using systemd-networkd as the renderer you can directly use a networkd *.netdev file to create one (and then configure it using either Netplan or a *.network file).

/etc/systemd/network/tun0.netdev
[NetDev] Name=tun0 Kind=tun

(This is the same kind of configuration that Netplan generates when rendering its configuration, and it will be automatically applied when Netplan does a networkctl reload.)

grawity
  • 501,077