]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
options: make 'tun' the default for '--dev' master
authorAntonio Quartulli <antonio@mandelbit.com>
Fri, 24 Jul 2026 05:55:23 +0000 (07:55 +0200)
committerGert Doering <gert@greenie.muc.de>
Fri, 24 Jul 2026 16:38:50 +0000 (18:38 +0200)
With this change, OpenVPN can be launched without specifying
any --dev option and it will start a `tun` (L3) tunnel with the
interface named `tunX`.
As before, this behaviour can be changed using --dev or --dev-type.

Existing configs won't see any behavioural change as they all
had to contain at least one --dev directive.

Change-Id: I0ca7b5b7ec1a01acaad222c99db137c94c88555a
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1537
Message-Id: <20260724055529.1376-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg37825.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
doc/man-sections/examples.rst
doc/man-sections/vpn-network-options.rst
sample/sample-config-files/client.conf
sample/sample-config-files/server.conf
src/openvpn/options.c

index 80ef2df0c5bf6757650209664ee22ef2ce43a9d1..416e576a8021612c0bc756a34e2b36e079db9f87 100644 (file)
@@ -63,6 +63,10 @@ you will get a weird feedback loop.
 Example 1: A simple tunnel without security (not recommended)
 -------------------------------------------------------------
 
+Since :code:`tun` is the default device type, ``--dev`` is optional; when it
+is omitted OpenVPN creates a dynamically-named ``tunX`` device. The examples
+below still name the device (``--dev tun1``) explicitly for clarity.
+
 On bob::
 
    openvpn --remote alice.example.com --dev tun1 \
index 33ebedb5ef22b8fec0d97a28984d7322d9268987..960c6addf25a2cba21524c19d6953a18d0581248 100644 (file)
@@ -50,6 +50,10 @@ routing.
   :code:`null` or an arbitrary name string (:code:`X` can be omitted for
   a dynamic device.)
 
+  If neither ``--dev`` nor ``--dev-type`` is specified, OpenVPN defaults to
+  :code:`tun`, i.e. it creates a dynamically-named :code:`tunX` device and
+  runs a layer-3 tunnel.
+
   See examples section below for an example on setting up a TUN device.
 
   You must use either tun devices on both ends of the connection or tap
index 53b8027db113da29a5255f0f98999751ed2ce373..1806b249ab4ed31cee6f19d6877b111b22a99bc9 100644 (file)
@@ -20,6 +20,8 @@ client
 # On most systems, the VPN will not function
 # unless you partially or fully disable
 # the firewall for the TUN/TAP interface.
+# "tun" is the default device type, so the
+# "dev tun" line below is optional.
 ;dev tap
 dev tun
 
index 8943c34e924d417df1dd42ac051c6cdd5b072e42..924fb960036a8c8fb2fffdfcb4aa3ba50fc2c018 100644 (file)
@@ -49,6 +49,8 @@ proto udp
 # On most systems, the VPN will not function
 # unless you partially or fully disable/open
 # the firewall for the TUN/TAP interface.
+# "tun" is the default device type, so the
+# "dev tun" line below is optional.
 ;dev tap
 dev tun
 
index d4675cab48e5e6d2880f933c84a59657452a87c2..d0f447cf34901c6ed2f782b8093c7a9b30ef5727 100644 (file)
@@ -189,7 +189,8 @@ static const char usage_message[] =
     " or --socks-proxy"
     " is used).\n"
     "--nobind        : Do not bind to local address and port.\n"
-    "--dev tunX|tapX : tun/tap device (X can be omitted for dynamic device.\n"
+    "--dev tunX|tapX : tun/tap device (X can be omitted for dynamic device).\n"
+    "                  Defaults to \"tun\" if neither --dev nor --dev-type is given.\n"
     "--dev-type dt   : Which device type are we using? (dt = tun or tap) Use\n"
     "                  this option only if the tun/tap device used with --dev\n"
     "                  does not begin with \"tun\" or \"tap\".\n"
@@ -803,6 +804,7 @@ init_options(struct options *o)
     gc_init(&o->dns_options.gc);
 
     o->mode = MODE_POINT_TO_POINT;
+    o->dev = "tun";
     o->topology = TOP_UNDEF;
     o->ce.proto = PROTO_UDP;
     o->ce.af = AF_UNSPEC;