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:

83452

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.6 (45 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-02-27
duckdb - 1.4.4
Ebuild name:

dev-db/duckdb-1.4.4

Description

high-performance analytical database system

Added to portage

2026-02-27

element-desktop-bin - 1.12.11
Ebuild name:

net-im/element-desktop-bin-1.12.11

Description

A glossy Matrix collaboration client for desktop (binary package

Added to portage

2026-02-27

file - 5.47
Ebuild name:

sys-apps/file-5.47

Description

Identify a file's format by scanning binary data for patterns

Added to portage

2026-02-27

framework-tool-tui - 0.8.0
Ebuild name:

app-laptop/framework-tool-tui-0.8.0

Description

TUI for controlling and monitoring Framework Computers hardware

Added to portage

2026-02-27

freerdp - 3.23.0
Ebuild name:

net-misc/freerdp-3.23.0

Description

Free implementation of the Remote Desktop Protocol

Added to portage

2026-02-27

gopls - 0.21.1
Ebuild name:

dev-go/gopls-0.21.1

Description

Added to portage

2026-02-27

lutris - 0.5.22
Ebuild name:

games-util/lutris-0.5.22

Description

An open source gaming platform for GNU/Linux

Added to portage

2026-02-27

ngtcp2 - 1.21.0
Ebuild name:

net-libs/ngtcp2-1.21.0

Description

Implementation of the IETF QUIC Protocol

Added to portage

2026-02-27

postgresql - 14.22
Ebuild name:

dev-db/postgresql-14.22

Description

PostgreSQL RDBMS

Added to portage

2026-02-27

postgresql - 15.17
Ebuild name:

dev-db/postgresql-15.17

Description

PostgreSQL RDBMS

Added to portage

2026-02-27

postgresql - 16.13
Ebuild name:

dev-db/postgresql-16.13

Description

PostgreSQL RDBMS

Added to portage

2026-02-27

postgresql - 17.9
Ebuild name:

dev-db/postgresql-17.9

Description

PostgreSQL RDBMS

Added to portage

2026-02-27

postgresql - 18.3
Ebuild name:

dev-db/postgresql-18.3

Description

PostgreSQL RDBMS

Added to portage

2026-02-27

signal-desktop-bin - 8.0.0
Ebuild name:

net-im/signal-desktop-bin-8.0.0

Description

Allows you to send and receive messages of Signal Messenger on your

Added to portage

2026-02-27

synapse - 1.148.0
Ebuild name:

net-im/synapse-1.148.0

Description

Reference implementation of Matrix homeserver

Added to portage

2026-02-27

2026-02-26
ansible-compat - 25.12.1
Ebuild name:

dev-python/ansible-compat-25.12.1

Description

Contains functions that facilitate working with various versions

Added to portage

2026-02-26

awscli - 1.44.47
Ebuild name:

app-admin/awscli-1.44.47

Description

Universal Command Line Environment for AWS

Added to portage

2026-02-26

bandit - 1.9.4
Ebuild name:

dev-python/bandit-1.9.4

Description

A security linter from OpenStack Security

Added to portage

2026-02-26

boto3 - 1.42.57
Ebuild name:

dev-python/boto3-1.42.57

Description

The AWS SDK for Python

Added to portage

2026-02-26

botocore - 1.42.57
Ebuild name:

dev-python/botocore-1.42.57

Description

Low-level, data-driven core of boto 3

Added to portage

2026-02-26

ckb - 0.6.1-r1
Ebuild name:

app-misc/ckb-0.6.1-r1

Description

Corsair K65/K70/K95 Driver

Added to portage

2026-02-26

ckb - 0.6.2-r1
Ebuild name:

app-misc/ckb-0.6.2-r1

Description

Corsair K65/K70/K95 Driver

Added to portage

2026-02-26

clang - 22.1.0-r2
Ebuild name:

llvm-core/clang-22.1.0-r2

Description

C language family frontend for LLVM

Added to portage

2026-02-26

cli11 - 2.6.2
Ebuild name:

dev-cpp/cli11-2.6.2

Description

Command line parser for C++11

Added to portage

2026-02-26

electrum-ecc - 0.0.7
Ebuild name:

dev-python/electrum-ecc-0.0.7

Description

Pure python ctypes wrapper for libsecp256k1

Added to portage

2026-02-26

fakeredis - 2.34.1
Ebuild name:

dev-python/fakeredis-2.34.1

Description

Fake implementation of redis API for testing purposes

Added to portage

2026-02-26

freeorion - 0.5.1.2
Ebuild name:

games-strategy/freeorion-0.5.1.2

Description

Free turn-based space empire and galactic conquest game

Added to portage

2026-02-26

gfxreconstruct - 1.4.341.0
Ebuild name:

dev-debug/gfxreconstruct-1.4.341.0

Description

Graphics API Capture and Replay Tools

Added to portage

2026-02-26

install-xattr - 0.12
Ebuild name:

sys-apps/install-xattr-0.12

Description

Wrapper to coreutils install to preserve Filesystem Extended Attributes

Added to portage

2026-02-26

leancrypto - 1.6.0-r3
Ebuild name:

dev-libs/leancrypto-1.6.0-r3

Description

Lean cryptographic library usable for bare-metal environments

Added to portage

2026-02-26

libva-intel-media-driver - 26.1.2
Ebuild name:

media-libs/libva-intel-media-driver-26.1.2

Description

Intel Media Driver for VA-API (iHD)

Added to portage

2026-02-26

llvm - 22.1.0-r2
Ebuild name:

llvm-core/llvm-22.1.0-r2

Description

Low Level Virtual Machine

Added to portage

2026-02-26

mesa - 25.3.6
Ebuild name:

media-libs/mesa-25.3.6

Description

OpenGL-like graphic library for Linux

Added to portage

2026-02-26

mesa - 26.0.1
Ebuild name:

media-libs/mesa-26.0.1

Description

OpenGL-like graphic library for Linux

Added to portage

2026-02-26

mesa_clc - 25.3.6
Ebuild name:

dev-util/mesa_clc-25.3.6

Description

mesa_clc tool used for building OpenCL C to SPIR-V

Added to portage

2026-02-26

mesa_clc - 26.0.1
Ebuild name:

dev-util/mesa_clc-26.0.1

Description

mesa_clc tool used for building OpenCL C to SPIR-V

Added to portage

2026-02-26

nanobind - 2.12.0
Ebuild name:

dev-python/nanobind-2.12.0

Description

Tiny and efficient C++/Python bindings

Added to portage

2026-02-26

nbxmpp - 7.1.0
Ebuild name:

dev-python/nbxmpp-7.1.0

Description

Python library to use Jabber/XMPP networks in a non-blocking way

Added to portage

2026-02-26

pallets-sphinx-themes - 2.5.0
Ebuild name:

dev-python/pallets-sphinx-themes-2.5.0

Description

Sphinx themes for Pallets and related projects

Added to portage

2026-02-26

picard - 3.0.0_alpha3
Ebuild name:

media-sound/picard-3.0.0_alpha3

Description

Cross-platform music tagger

Added to portage

2026-02-26

pytest-check - 2.7.0
Ebuild name:

dev-python/pytest-check-2.7.0

Description

pytest plugin that allows multiple failures per test

Added to portage

2026-02-26

python-ironicclient - 6.0.0
Ebuild name:

dev-python/python-ironicclient-6.0.0

Description

Python bindings for the Ironic API

Added to portage

2026-02-26

python-neutronclient - 11.8.0
Ebuild name:

dev-python/python-neutronclient-11.8.0

Description

A client for the OpenStack Quantum API

Added to portage

2026-02-26

python-swiftclient - 4.10.0
Ebuild name:

dev-python/python-swiftclient-4.10.0

Description

Python bindings to the OpenStack Object Storage API

Added to portage

2026-02-26

qtox - 1.18.4
Ebuild name:

net-im/qtox-1.18.4

Description

Instant messaging client using the encrypted p2p Tox protocol

Added to portage

2026-02-26

redis - 7.2.1
Ebuild name:

dev-python/redis-7.2.1

Description

Python client for Redis key-value store

Added to portage

2026-02-26

sphinx-autodoc-typehints - 3.8.0
Ebuild name:

dev-python/sphinx-autodoc-typehints-3.8.0

Description

Type hints support for the Sphinx autodoc extension

Added to portage

2026-02-26

stripe - 14.4.0
Ebuild name:

dev-python/stripe-14.4.0

Description

Stripe Python bindings

Added to portage

2026-02-26

tempest - 46.1.0
Ebuild name:

dev-python/tempest-46.1.0

Description

OpenStack Integration Testing

Added to portage

2026-02-26

tox - 0.2.22
Ebuild name:

net-libs/tox-0.2.22

Description

Encrypted P2P, messaging, and audio/video calling platform

Added to portage

2026-02-26

tox - 4.46.3
Ebuild name:

dev-python/tox-4.46.3

Description

virtualenv-based automation of test activities

Added to portage

2026-02-26

toxic - 0.16.2
Ebuild name:

net-im/toxic-0.16.2

Description

A curses-based client for Tox

Added to portage

2026-02-26

translate-toolkit - 3.19.2
Ebuild name:

dev-python/translate-toolkit-3.19.2

Description

Toolkit to convert between many translation formats

Added to portage

2026-02-26

virtualenv - 20.39.1
Ebuild name:

dev-python/virtualenv-20.39.1

Description

Virtual Python Environment builder

Added to portage

2026-02-26

xkbcomp - 1.5.0-r2
Ebuild name:

x11-apps/xkbcomp-1.5.0-r2

Description

XKB keyboard description compiler

Added to portage

2026-02-26

xkeyboard-config - 2.47
Ebuild name:

x11-misc/xkeyboard-config-2.47

Description

X keyboard configuration database

Added to portage

2026-02-26

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