from small one page howto to huge articles all in one place

search text in:




Other .linuxhowtos.org sites: www.linuxhowtos.org
toolsntoys.linuxhowtos.org



Last additions:
How to make X listen on port 6000

How to make X listen on port 6000

words:

34

views:

87889

userrating:

average rating: 1.2 (52 votes) (1=very good 6=terrible)


May, 25th 2007:
April, 26th 2007:
Apr, 10th. 2007:
Druckversion . pdf icon
You are here: Tutorials per portage category->net-misc->openvpn

OpenVPN primer


There are as many advantages to VPN tunnels as there are different VPN scenarios. One easy implementation is the "OpenVPN via tun-device" solution. An example: you'd like to connect your laptop to your LAN at home so that you can use your mail client without reconfiguring it anytime you switch from home to internet and back. Let's say your mail-server is 192.168.1.10 in your LAN (192.168.1.0/24) at home, and you have got a router/firewall providing access to the Internet. You connect from work or school and want to read mail. OpenVPN can create two virtual devices for you when connecting two computers through an encrypted tunnel. Naturally you then have the possibility of forwarding traffic into the networks behind them, and thus would be "virtually connected" to your LAN behind the firewall. To enable this, either your firewall or a server behind it should run OpenVPN (if you choose a server in your LAN, you'll have to forward the destination port to the OpenVPN server).

Here's what you need to do:
Code Listing 1: Enable the tun module in your kernel: Kernel config - tun module
          [*] Networking support    
Networking options --->
[ ] Amateur Radio support --->
< > IrDA (infrared) subsystem support --->
< > Bluetooth subsystem support --->
[*] Network device support
< > Dummy net driver support
< > Bonding driver support
< > EQL (serial line load balancing) support
Universal TUN/TAP device driver support
// This option must be enabled


Make sure this module exists and can be loaded. Next, install OpenVPN and it dependencies.
Code Listing 2: Install OpenVPN
emerge openvpn

Now on both server and client, create a directory for your configuration:

Code Listing 3: Make directory
mkdir /etc/openvpn    
mkdir /etc/openvpn/myhomelan


Inside that directory, create a shared key for your VPN session and copy that key to the client's directory, /etc/openvpn/myhomelan.

Code Listing 4: Generate shared key
cd /etc/openvpn/myhomelan    
openvpn --genkey --secret myhomelan-key.txt


Now for the tricky part, the routing. It is important that the two tun devices on the client and server use IP addresses from the same subnet. The configuration files shown below list the type of device, the two end-points of the tunnel, the compression method and the UDP-port on which the tunnel is established. Finally privileges are dropped to user and group as listed:

Code Listing 5: Server-side configuration file /etc/openvpn/myhomelan/local.conf
dev tun    
ifconfig 172.16.1.1 172.16.1.20 // IP of the local
// tun device and its peer
secret /etc/openvpn/myhomelan/myhomelan-key.txt
comp-lzo
port 5000
user nobody
group nobody


The client's configuration needs the tunnel's destination address. This is often a dynamic DNS address, sometimes a fixed IP, depending on your ISP. You also need to route to your home LAN (192.168.1.0 in our example). You can call a shell script from the configuration file that accordingly sets a route.

Code Listing 6: Client-side configuration file /etc/openvpn/myhomelan/local.conf
remote    // or your VPN 
// server's external IP if you have a fixed one
dev tun
ifconfig 172.16.1.20 172.16.1.1 // IP of the local tun
// device and its peer
secret /etc/openvpn/myhomelan/myhomelan-key.txt
comp-lzo
port 5000
user nobody
group nobody
up /etc/openvpn/myhomelan/route.sh // sets up the route
//to the network behind the VPN server


The route command would need to set the client's gateway for the network 192.168.1.0 to its peer's address (172.16.1.1 in our setup).

Code Listing 7: /etc/openvpn/myhomelan/route.sh
#!/bin/bash    
route add -net 192.168.1.0 netmask 255.255.255.0 gw 172.16.1.1


That's it. Start OpenVPN on the server and the client, and check the devices with ifconfig and the routes with route -n. Success!

From http://www.gentoo.org/news/en/gwn/20041011-newsletter.xml
rate this article:
current rating: average rating: 1.5 (69 votes) (1=very good 6=terrible)
Your rating:
Very good (1) Good (2) ok (3) average (4) bad (5) terrible (6)

back



Support us on Content Nation

New Packages

- as rdf newsfeed
- as rss newsfeed
- as Atom newsfeed
2026-08-23
ggml - 0.21.0-r1
Ebuild name:

sci-ml/ggml-0.21.0-r1

Description

Tensor library for machine learning

Added to portage

2026-08-23

2026-08-22
asteval - 1.0.10
Ebuild name:

dev-python/asteval-1.0.10

Description

Evaluator of Python expression using ast module

Added to portage

2026-08-22

boto3 - 1.43.78
Ebuild name:

dev-python/boto3-1.43.78

Description

The AWS SDK for Python

Added to portage

2026-08-22

botocore - 1.43.78
Ebuild name:

dev-python/botocore-1.43.78

Description

Low-level, data-driven core of boto 3

Added to portage

2026-08-22

brotlicffi - 1.2.0.2
Ebuild name:

dev-python/brotlicffi-1.2.0.2

Description

Python binding to the Brotli library

Added to portage

2026-08-22

cachelib - 0.16.1
Ebuild name:

dev-python/cachelib-0.16.1

Description

Collection of cache libraries in the same API interface. Extracted from

Added to portage

2026-08-22

cfg-update - 1.11.0
Ebuild name:

app-portage/cfg-update-1.11.0

Description

Easy to use GUI & CLI alternative for etc-update

Added to portage

2026-08-22

cgreen - 1.7.0
Ebuild name:

dev-libs/cgreen-1.7.0

Description

Unit test and mocking framework for C and C++

Added to portage

2026-08-22

charm - 6.10.2
Ebuild name:

sys-cluster/charm-6.10.2

Description

Message-passing parallel language and runtime system

Added to portage

2026-08-22

cjose - 0.6.2.8
Ebuild name:

dev-libs/cjose-0.6.2.8

Description

C library implementing the Javascript Object Signing and Encryption (JOSE)

Added to portage

2026-08-22

confuse - 3.4
Ebuild name:

dev-libs/confuse-3.4

Description

a configuration file parser library

Added to portage

2026-08-22

cramjam - 2.12.0
Ebuild name:

dev-python/cramjam-2.12.0

Description

Thin Python bindings to de/compression algorithms in Rust

Added to portage

2026-08-22

cython - 3.3.0
Ebuild name:

dev-python/cython-3.3.0

Description

A Python to C compiler

Added to portage

2026-08-22

dbutils - 3.2.0
Ebuild name:

dev-python/dbutils-3.2.0

Description

Database connections for multi-threaded environments

Added to portage

2026-08-22

dealii - 9.8.0
Ebuild name:

sci-libs/dealii-9.8.0

Description

Solving partial differential equations with the finite element method

Added to portage

2026-08-22

dependency-groups - 1.3.2
Ebuild name:

dev-python/dependency-groups-1.3.2

Description

A tool for resolving PEP 735 Dependency Group data

Added to portage

2026-08-22

faker - 40.37.0
Ebuild name:

dev-python/faker-40.37.0

Description

A Python package that generates fake data for you

Added to portage

2026-08-22

fwupd - 2.1.7
Ebuild name:

sys-apps/fwupd-2.1.7

Description

Aims to make updating firmware on Linux automatic, safe and reliable

Added to portage

2026-08-22

libcap-ng - 0.9.5-r1
Ebuild name:

sys-libs/libcap-ng-0.9.5-r1

Description

POSIX 1003.1e capabilities

Added to portage

2026-08-22

libplatform - 2.2.0
Ebuild name:

dev-libs/libplatform-2.2.0

Description

Platform support library used by libCEC and binary add-ons for Kodi

Added to portage

2026-08-22

libsecret - 0.21.7
Ebuild name:

app-crypt/libsecret-0.21.7

Description

GObject library for accessing the freedesktop.org Secret Service API

Added to portage

2026-08-22

libsecret - 0.21.7-r1
Ebuild name:

app-crypt/libsecret-0.21.7-r1

Description

GObject library for accessing the freedesktop.org Secret Service API

Added to portage

2026-08-22

libxmlb - 0.3.29
Ebuild name:

dev-libs/libxmlb-0.3.29

Description

Library to help create and query binary XML blobs

Added to portage

2026-08-22

mac - 13.26
Ebuild name:

media-sound/mac-13.26

Description

Monkey's Audio Codecs

Added to portage

2026-08-22

mesa - 26.2.1
Ebuild name:

media-libs/mesa-26.2.1

Description

OpenGL-like graphic library for Linux

Added to portage

2026-08-22

mesa_clc - 26.2.1
Ebuild name:

dev-util/mesa_clc-26.2.1

Description

mesa_clc tool used for building OpenCL C to SPIR-V

Added to portage

2026-08-22

nanobind - 3.0.0
Ebuild name:

dev-python/nanobind-3.0.0

Description

Tiny and efficient C++/Python bindings

Added to portage

2026-08-22

ncspot - 1.4.0
Ebuild name:

media-sound/ncspot-1.4.0

Description

ncurses Spotify client written in Rust using librespot

Added to portage

2026-08-22

nss - 3.127
Ebuild name:

dev-libs/nss-3.127

Description

Mozilla's Network Security Services library that implements PKI support

Added to portage

2026-08-22

openpgp-keys-zsh - 2026.07.12
Ebuild name:

sec-keys/openpgp-keys-zsh-2026.07.12

Description

PGP keys used to sign ZSH releases

Added to portage

2026-08-22

portage - 3.0.82
Ebuild name:

sys-apps/portage-3.0.82

Description

The package management and distribution system for Gentoo

Added to portage

2026-08-22

portalocker - 4.2.0
Ebuild name:

dev-python/portalocker-4.2.0

Description

A library for Python file locking

Added to portage

2026-08-22

powercap-utils - 0.6.0
Ebuild name:

sys-power/powercap-utils-0.6.0

Description

C bindings to the Linux Power Capping Framework in sysfs

Added to portage

2026-08-22

rss2email - 3.14-r4
Ebuild name:

net-mail/rss2email-3.14-r4

Description

A python script that converts RSS/Atom newsfeeds to email

Added to portage

2026-08-22

sabctools - 9.7.0
Ebuild name:

dev-python/sabctools-9.7.0

Description

Module providing raw yEnc encoding/decoding for SABnzbd

Added to portage

2026-08-22

scipy - 1.18.1
Ebuild name:

dev-python/scipy-1.18.1

Description

Scientific algorithms library for Python

Added to portage

2026-08-22

shadowsocks-libev - 3.3.6
Ebuild name:

net-proxy/shadowsocks-libev-3.3.6

Description

A lightweight secured SOCKS5 proxy for embedded devices and low e

Added to portage

2026-08-22

sphinx-argparse - 0.6.1
Ebuild name:

dev-python/sphinx-argparse-0.6.1

Description

Sphinx extension that automatically documents argparse commands an

Added to portage

2026-08-22

spidermonkey - 140.14.0
Ebuild name:

dev-lang/spidermonkey-140.14.0

Description

Mozilla's JavaScript engine written in C and C++

Added to portage

2026-08-22

spidermonkey - 153.1.0
Ebuild name:

dev-lang/spidermonkey-153.1.0

Description

Mozilla's JavaScript engine written in C and C++

Added to portage

2026-08-22

spirv-llvm-translator - 24.0.0_pre20260820
Ebuild name:

dev-util/spirv-llvm-translator-24.0.0_pre20260820

Description

Bi-directional translator between SPIR-V and LLVM

Added to portage

2026-08-22

symbols-nerd-font - 3.5.1
Ebuild name:

media-fonts/symbols-nerd-font-3.5.1

Description

Symbols-only font containing the Nerd Font icons

Added to portage

2026-08-22

tree-sitter-cmake - 0.7.4
Ebuild name:

dev-libs/tree-sitter-cmake-0.7.4

Description

CMake grammar for tree-sitter

Added to portage

2026-08-22

tree-sitter-ocaml - 0.25.0
Ebuild name:

dev-libs/tree-sitter-ocaml-0.25.0

Description

OCaml grammar for Tree-sitter

Added to portage

2026-08-22

tree-sitter-scala - 0.26.2
Ebuild name:

dev-libs/tree-sitter-scala-0.26.2

Description

Scala grammar for Tree-sitter

Added to portage

2026-08-22

wine-proton - 11.0.2
Ebuild name:

app-emulation/wine-proton-11.0.2

Description

Valve Software's fork of Wine

Added to portage

2026-08-22

wine-vanilla - 11.16
Ebuild name:

app-emulation/wine-vanilla-11.16

Description

Free implementation of Windows(tm) on Unix, without external patch

Added to portage

2026-08-22

rdf newsfeed | rss newsfeed | Atom newsfeed
Copyright 2004-2025 Sascha Nitsch Unternehmensberatung GmbH
- Copyright and legal notices -
Time to create this page: 54.9 ms