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:

87243

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-07-28
accountsservice - 23.13.9-r1
Ebuild name:

sys-apps/accountsservice-23.13.9-r1

Description

D-Bus interfaces for querying and manipulating user account inf

Added to portage

2026-07-28

accountsservice - 26.27.3
Ebuild name:

sys-apps/accountsservice-26.27.3

Description

D-Bus interfaces for querying and manipulating user account inform

Added to portage

2026-07-28

awscli - 1.45.57
Ebuild name:

app-admin/awscli-1.45.57

Description

Universal Command Line Environment for AWS

Added to portage

2026-07-28

boto3 - 1.43.57
Ebuild name:

dev-python/boto3-1.43.57

Description

The AWS SDK for Python

Added to portage

2026-07-28

botocore - 1.43.57
Ebuild name:

dev-python/botocore-1.43.57

Description

Low-level, data-driven core of boto 3

Added to portage

2026-07-28

c-blosc2 - 3.3.0
Ebuild name:

dev-libs/c-blosc2-3.3.0

Description

Blocking, shuffling and lossless compression library

Added to portage

2026-07-28

cachebox - 6.2.1
Ebuild name:

dev-python/cachebox-6.2.1

Description

The fastest memoizing and caching Python library written in Rust

Added to portage

2026-07-28

cssselect - 1.5.0
Ebuild name:

dev-python/cssselect-1.5.0

Description

Parse CSS3 Selectors and translate them to XPath 1.0

Added to portage

2026-07-28

deepdiff - 9.1.0
Ebuild name:

dev-python/deepdiff-9.1.0

Description

A library for comparing dictionaries, iterables, strings and other object

Added to portage

2026-07-28

fastapi - 0.140.7
Ebuild name:

dev-python/fastapi-0.140.7

Description

High performance framework, easy to learn, fast to code, ready for produ

Added to portage

2026-07-28

fastbencode - 0.3.11
Ebuild name:

dev-python/fastbencode-0.3.11

Description

Implementation of bencode with Rust implementation

Added to portage

2026-07-28

fastjsonschema - 2.22.1
Ebuild name:

dev-python/fastjsonschema-2.22.1

Description

Fast JSON schema validator for Python

Added to portage

2026-07-28

gdm - 49.3-r2
Ebuild name:

gnome-base/gdm-49.3-r2

Description

GNOME Display Manager for managing graphical display servers and user logins

Added to portage

2026-07-28

gnome-control-center - 49.8-r1
Ebuild name:

gnome-base/gnome-control-center-49.8-r1

Description

GNOME's main interface to configure various aspects of the

Added to portage

2026-07-28

gnome-flashback-herbstluftwm - 1.0
Ebuild name:

x11-wm/gnome-flashback-herbstluftwm-1.0

Description

GNOME Herbstluftwm session (via GNOME Flashback)

Added to portage

2026-07-28

gnome-shell-extension-appindicator - 65
Ebuild name:

gnome-extra/gnome-shell-extension-appindicator-65

Description

Support legacy, AppIndicators and KStatusNotifier

Added to portage

2026-07-28

hypothesis - 6.161.8
Ebuild name:

dev-python/hypothesis-6.161.8

Description

A library for property based testing

Added to portage

2026-07-28

inline-snapshot - 0.35.3
Ebuild name:

dev-python/inline-snapshot-0.35.3

Description

Create and update inline snapshots in your Python tests

Added to portage

2026-07-28

krita - 6.0.3
Ebuild name:

media-gfx/krita-6.0.3

Description

Free digital painting application. Digital Painting, Creative Freedom

Added to portage

2026-07-28

libwebsockets - 5.0.0-r1
Ebuild name:

net-libs/libwebsockets-5.0.0-r1

Description

A flexible pure-C library for implementing network protocols

Added to portage

2026-07-28

meson-mode - 0.4
Ebuild name:

app-emacs/meson-mode-0.4

Description

A GNU Emacs major mode for Meson build-system files

Added to portage

2026-07-28

pyproject-fmt - 2.26.0
Ebuild name:

dev-python/pyproject-fmt-2.26.0

Description

Format your pyproject.toml file

Added to portage

2026-07-28

pyquery - 2.0.2
Ebuild name:

dev-python/pyquery-2.0.2

Description

A jQuery-like library for python

Added to portage

2026-07-28

pyquery - 2.1.0
Ebuild name:

dev-python/pyquery-2.1.0

Description

A jQuery-like library for python

Added to portage

2026-07-28

python-lsp-server - 1.15.0
Ebuild name:

dev-python/python-lsp-server-1.15.0

Description

Python Language Server for the Language Server Protocol

Added to portage

2026-07-28

ruff - 0.16.0
Ebuild name:

dev-util/ruff-0.16.0

Description

An extremely fast Python linter, written in Rust

Added to portage

2026-07-28

sqlglot - 30.14.0
Ebuild name:

dev-python/sqlglot-30.14.0

Description

An easily customizable SQL parser and transpiler

Added to portage

2026-07-28

tekore - 6.2.0
Ebuild name:

dev-python/tekore-6.2.0

Description

Spotify Web API client

Added to portage

2026-07-28

tqdm - 4.70.0
Ebuild name:

dev-python/tqdm-4.70.0

Description

Add a progress meter to your loops in a second

Added to portage

2026-07-28

ttyd - 1.7.7-r2
Ebuild name:

www-apps/ttyd-1.7.7-r2

Description

ttyd, a simple command-line tool for sharing terminal over the web

Added to portage

2026-07-28

twine - 7.0.0
Ebuild name:

dev-python/twine-7.0.0

Description

Collection of utilities for publishing packages on PyPI

Added to portage

2026-07-28

2026-07-27
atari800 - 7.1.2
Ebuild name:

games-emulation/atari800-7.1.2

Description

Emulator of Atari 8-bit computer systems and 5200 game console

Added to portage

2026-07-27

backrefs - 8.0
Ebuild name:

dev-python/backrefs-8.0

Description

Wrapper around re or regex that adds additional back references

Added to portage

2026-07-27

cares-tools - 0.4
Ebuild name:

net-dns/cares-tools-0.4

Description

c-ares tools host, nslookup

Added to portage

2026-07-27

courier - 2.0.6
Ebuild name:

mail-mta/courier-2.0.6

Description

An MTA designed specifically for maildirs

Added to portage

2026-07-27

fastjsonschema - 2.22.0
Ebuild name:

dev-python/fastjsonschema-2.22.0

Description

Fast JSON schema validator for Python

Added to portage

2026-07-27

gamescope - 3.16.25-r1
Ebuild name:

gui-wm/gamescope-3.16.25-r1

Description

Efficient micro-compositor for running games

Added to portage

2026-07-27

gcc - 13.4.1_p20260722
Ebuild name:

sys-devel/gcc-13.4.1_p20260722

Description

The GNU Compiler Collection

Added to portage

2026-07-27

gcc - 14.4.1_p20260723
Ebuild name:

sys-devel/gcc-14.4.1_p20260723

Description

The GNU Compiler Collection

Added to portage

2026-07-27

gcc - 15.3.1_p20260724
Ebuild name:

sys-devel/gcc-15.3.1_p20260724

Description

The GNU Compiler Collection

Added to portage

2026-07-27

gcc - 16.1.1_p20260725
Ebuild name:

sys-devel/gcc-16.1.1_p20260725

Description

The GNU Compiler Collection

Added to portage

2026-07-27

gcc - 17.0.0_p20260726
Ebuild name:

sys-devel/gcc-17.0.0_p20260726

Description

The GNU Compiler Collection

Added to portage

2026-07-27

geekbench-ai - 1.7.0
Ebuild name:

app-benchmarks/geekbench-ai-1.7.0

Description

A Cross-Platform AI Benchmark for Android, iOS, Linux, MacOS and

Added to portage

2026-07-27

git-sources - 7.2_rc5
Ebuild name:

sys-kernel/git-sources-7.2_rc5

Description

The very latest -git version of the Linux kernel

Added to portage

2026-07-27

gitpython - 3.1.57
Ebuild name:

dev-python/gitpython-3.1.57

Description

Library used to interact with Git repositories

Added to portage

2026-07-27

gnome-flashback - 3.58.0-r1
Ebuild name:

gnome-base/gnome-flashback-3.58.0-r1

Description

GNOME Flashback session

Added to portage

2026-07-27

herbstluftwm - 0.9.6-r1
Ebuild name:

x11-wm/herbstluftwm-0.9.6-r1

Description

A manual tiling window manager for X

Added to portage

2026-07-27

jupyterlab-desktop-bin - 4.6.2.1
Ebuild name:

sci-misc/jupyterlab-desktop-bin-4.6.2.1

Description

JupyterLab desktop application, based on Electron

Added to portage

2026-07-27

libGLw - 8.0.0-r2
Ebuild name:

x11-libs/libGLw-8.0.0-r2

Description

Mesa GLw library

Added to portage

2026-07-27

libxmp - 4.7.2
Ebuild name:

media-libs/libxmp-4.7.2

Description

Library that renders module files to PCM data

Added to portage

2026-07-27

libzia - 4.72-r1
Ebuild name:

dev-libs/libzia-4.72-r1

Description

Platform abstraction code for tucnak package

Added to portage

2026-07-27

mattermost-desktop-bin - 6.3.0_rc2
Ebuild name:

net-im/mattermost-desktop-bin-6.3.0_rc2

Description

Mattermost Desktop application

Added to portage

2026-07-27

nghttp3 - 1.18.0
Ebuild name:

net-libs/nghttp3-1.18.0

Description

HTTP/3 library written in C

Added to portage

2026-07-27

ngtcp2 - 1.25.0
Ebuild name:

net-libs/ngtcp2-1.25.0

Description

Implementation of the IETF QUIC Protocol

Added to portage

2026-07-27

phonenumbers - 9.0.35
Ebuild name:

dev-python/phonenumbers-9.0.35

Description

Python port of Google's libphonenumber

Added to portage

2026-07-27

prompt-toolkit - 3.0.53
Ebuild name:

dev-python/prompt-toolkit-3.0.53

Description

Building powerful interactive command lines in Python

Added to portage

2026-07-27

pygments - 2.20.0
Ebuild name:

dev-python/pygments-2.20.0

Description

Pygments is a syntax highlighting package written in Python

Added to portage

2026-07-27

pyproject-fmt - 2.25.4
Ebuild name:

dev-python/pyproject-fmt-2.25.4

Description

Format your pyproject.toml file

Added to portage

2026-07-27

svxlink - 26.05.1
Ebuild name:

media-radio/svxlink-26.05.1

Description

Multi Purpose Voice Services System, including Qtel for EchoLink

Added to portage

2026-07-27

typeguard - 4.6.0
Ebuild name:

dev-python/typeguard-4.6.0

Description

Run-time type checker for Python

Added to portage

2026-07-27

urwid - 4.0.8
Ebuild name:

dev-python/urwid-4.0.8

Description

Curses-based user interface library for Python

Added to portage

2026-07-27

xephem - 4.2.0-r1
Ebuild name:

sci-astronomy/xephem-4.2.0-r1

Description

Interactive tool for astronomical ephemeris and sky simulation

Added to portage

2026-07-27

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