From patchwork Mon Jun 29 00:49:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Wilhelm X-Patchwork-Id: 1186 X-Patchwork-Delegate: davids@openvpn.net Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id aIvvJm7H+V49QAAAIUCqbw for ; Mon, 29 Jun 2020 06:50:22 -0400 Received: from proxy20.mail.ord1d.rsapps.net ([172.30.191.6]) by director9.mail.ord1d.rsapps.net with LMTP id ICjDJm7H+V57egAAalYnBA ; Mon, 29 Jun 2020 06:50:22 -0400 Received: from smtp17.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy20.mail.ord1d.rsapps.net with LMTP id SCmfJm7H+V6JeAAAsk8m8w ; Mon, 29 Jun 2020 06:50:22 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp17.gate.ord1d.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=rfc2324.org X-Suspicious-Flag: YES X-Classification-ID: 537944a2-b9f6-11ea-b187-5254008de1cb-1-1 Received: from [216.105.38.7] ([216.105.38.7:47832] helo=lists.sourceforge.net) by smtp17.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 19/77-26787-C67C9FE5; Mon, 29 Jun 2020 06:50:20 -0400 Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1jprLu-0004kn-1m; Mon, 29 Jun 2020 10:49:30 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jprLs-0004ka-T9 for openvpn-devel@lists.sourceforge.net; Mon, 29 Jun 2020 10:49:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Subject:References:In-Reply-To:Message-Id:Date:Cc: To:From:Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=X+Hzw9rR6Nolpifxflckevo2N874Rv9USY7FqKZdHIU=; b=i9fFP25irpTtUbP0hufsPYrHW5 3YFTEyK5/ozxgcYkUD+sh9yhdsKgZ+1voEfZ+vzmaXkWrxBb1bsTrkobXHhBWoTFSnDTXg0unXs4k X0XiGPr8F4gqvasEdP+DN7ec+k4VQddl3DhpZwYCfKVAGQEDLkBb70jwHNcL1Raavmkc=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Subject:References:In-Reply-To:Message-Id:Date:Cc:To:From:Sender:Reply-To :MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=X+Hzw9rR6Nolpifxflckevo2N874Rv9USY7FqKZdHIU=; b=SCxnSuaDSUwfuRhyJvVsSFaZ+M izL/kYE8SkJONxN8ghKVN6rlCmHE6WwrdyuzJsn0jc3fYAEgWsWetBHKxUMK3sTXWy4GoY4tZpWro PoFw2V7Bjk7ObTazmOx7XFW1PeYsOt7NctMYGr55jA/0Owq9F4auwa8F6bhg6GWclbxw=; Received: from mail.rfc2324.org ([31.172.8.67]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.2) id 1jprLq-005zvE-PM for openvpn-devel@lists.sourceforge.net; Mon, 29 Jun 2020 10:49:28 +0000 Received: from rfc2324.org ([31.172.8.84] helo=principal.rfc2324.org) by mail.rfc2324.org with esmtp rfc2324.org Mailserver id 1jprLh-0005qn-0K; Mon, 29 Jun 2020 12:49:19 +0200 Received: by principal.rfc2324.org (Postfix, from userid 666) id C84998F30A; Mon, 29 Jun 2020 12:49:16 +0200 (CEST) From: Maximilian Wilhelm To: openvpn-devel@lists.sourceforge.net Date: Mon, 29 Jun 2020 12:49:08 +0200 Message-Id: <1593427748-29801-3-git-send-email-max@rfc2324.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1593427748-29801-1-git-send-email-max@rfc2324.org> References: <1593197385-30618-2-git-send-email-max@rfc2324.org> <1593427748-29801-1-git-send-email-max@rfc2324.org> X-SA-Exim-Connect-IP: 31.172.8.84 X-SA-Exim-Mail-From: max@principal.rfc2324.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.rfc2324.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.2 X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on mail.rfc2324.org) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-Headers-End: 1jprLq-005zvE-PM Subject: [Openvpn-devel] [PATCH v2 2/2] Documentation for --bind-dev / VRFs on Linux X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maximilian Wilhelm MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Maximilian Wilhelm Signed-off-by: Maximilian Wilhelm --- doc/man-sections/vrf.rst | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 doc/man-sections/vrf.rst diff --git a/doc/man-sections/vrf.rst b/doc/man-sections/vrf.rst new file mode 100644 index 0000000..f395db1 --- /dev/null +++ b/doc/man-sections/vrf.rst @@ -0,0 +1,75 @@ +Virtual Routing and Forwarding +--------------------------------------- + +Options in this section relates to configuration of virtual routing and +forwarding in combination with the underlying operating system. + +As of today this is only supported on Linux, a kernel >= 4.9 is recommended. + +This could come in handy when for example the external network should be only +used as a means to connect to some VPN endpoints and all regular traffic +should only be routed through any tunnel(s). +This could be achieved by setting up a VRF and configuring the interface +connected to the external network to be part of the VRF. The examples below +will cover this setup. + +Another option would be to put the tun/tap interface into a VRF. This could +be done by an up-script which uses the `ip link set` command shown below. + + +**VRF setup with iproute2** + +Create VRF `vrf_external` and map it to routing table `1023` + +:: + + ip link add vrf_external type vrf table 1023 + +Move `eth0` into `vrf_external` + +:: + + ip link set master vrf_external dev eth0 + +Any prefixes configured on `eth0` will be moved from the `main` routing +table into routing table `1023` + + +**VRF setup with ifupdown** + +For Debian based Distributions `ifupdown2` provides an almost drop-in +replacement for `ifupdown` including VRFs and other features. +A configuration for an interface `eth0` being part of VRF `vrf_external` +could look like this: + +:: + + auto eth0 + iface eth0 + address 192.0.2.42/24 + address 2001:db8:08:15::42/64 + gateway 192.0.2.1 + gateway 2001:db8:08:15::1 + vrf vrf_external + + auto vrf_external + iface vrf_external + vrf-table 1023 + + +**OpenVPN config** + +--bind-dev device + Set the device to bind the server socket to to the VRF + + --bind-dev vrf_external + + +**Further reading** + +Wikipedia has nice page one VRFs: https://en.wikipedia.org/wiki/Virtual_routing_and_forwarding + +This talk from the Network Track of FrOSCon 2018 provides an overview about +advanced layer 2 and layer 3 features of Linux + - Slides: https://www.slideshare.net/BarbarossaTM/l2l3-fr-fortgeschrittene-helle-und-dunkle-magie-im-linuxnetzwerkstack + - Video (german): https://media.ccc.de/v/froscon2018-2247-l2_l3_fur_fortgeschrittene_-_helle_und_dunkle_magie_im_linux-netzwerkstack