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:

82290

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.7 (41 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
2025-12-04
djbdns - 1.05-r42
Ebuild name:

net-dns/djbdns-1.05-r42

Description

Collection of DNS client/server software

Added to portage

2025-12-04

poppler - 25.12.0
Ebuild name:

app-text/poppler-25.12.0

Description

PDF rendering library based on the xpdf-3.0 code base

Added to portage

2025-12-04

2025-12-03
ansible-compat - 25.12.0
Ebuild name:

dev-python/ansible-compat-25.12.0

Description

Contains functions that facilitate working with various versions

Added to portage

2025-12-03

aws-sam-translator - 1.105.0
Ebuild name:

dev-python/aws-sam-translator-1.105.0

Description

A library that transform SAM templates into AWS CloudFormatio

Added to portage

2025-12-03

awscli - 1.43.7
Ebuild name:

app-admin/awscli-1.43.7

Description

Universal Command Line Environment for AWS

Added to portage

2025-12-03

borgbackup - 1.4.3
Ebuild name:

app-backup/borgbackup-1.4.3

Description

Deduplicating backup program with compression and authenticated encrypt

Added to portage

2025-12-03

boto3 - 1.42.1
Ebuild name:

dev-python/boto3-1.42.1

Description

The AWS SDK for Python

Added to portage

2025-12-03

botocore - 1.42.1
Ebuild name:

dev-python/botocore-1.42.1

Description

Low-level, data-driven core of boto 3

Added to portage

2025-12-03

django - 4.2.27
Ebuild name:

dev-python/django-4.2.27

Description

High-level Python web framework

Added to portage

2025-12-03

django - 5.1.15
Ebuild name:

dev-python/django-5.1.15

Description

High-level Python web framework

Added to portage

2025-12-03

django - 5.2.9
Ebuild name:

dev-python/django-5.2.9

Description

High-level Python web framework

Added to portage

2025-12-03

gentoo-sources - 6.18.0
Ebuild name:

sys-kernel/gentoo-sources-6.18.0

Description

Full sources including the Gentoo patchset for the . kernel tree

Added to portage

2025-12-03

icaclient - 25.05.0.44-r1
Ebuild name:

net-misc/icaclient-25.05.0.44-r1

Description

ICA Client for Citrix Presentation servers

Added to portage

2025-12-03

indilib - 2.1.7
Ebuild name:

sci-libs/indilib-2.1.7

Description

INDI Astronomical Control Protocol library

Added to portage

2025-12-03

krita - 6.0.0_alpha_pre20251203
Ebuild name:

media-gfx/krita-6.0.0_alpha_pre20251203

Description

Free digital painting application. Digital Painting, Creati

Added to portage

2025-12-03

libnftnl - 1.3.1
Ebuild name:

net-libs/libnftnl-1.3.1

Description

Netlink API to the in-kernel nf_tables subsystem

Added to portage

2025-12-03

libsdl2 - 2.32.60
Ebuild name:

media-libs/libsdl2-2.32.60

Description

Simple Direct Media Layer

Added to portage

2025-12-03

libsdl3 - 3.2.28
Ebuild name:

media-libs/libsdl3-3.2.28

Description

Simple Direct Media Layer

Added to portage

2025-12-03

libwebsockets - 4.5.2
Ebuild name:

net-libs/libwebsockets-4.5.2

Description

A flexible pure-C library for implementing network protocols

Added to portage

2025-12-03

linux-docs - 6.18
Ebuild name:

sys-kernel/linux-docs-6.18

Description

Developer documentation generated from the Linux kernel

Added to portage

2025-12-03

linux-firmware - 20251125_p20251202
Ebuild name:

sys-kernel/linux-firmware-20251125_p20251202

Description

Linux firmware files

Added to portage

2025-12-03

numpydoc - 1.10.0
Ebuild name:

dev-python/numpydoc-1.10.0

Description

Sphinx extension to support docstrings in Numpy format

Added to portage

2025-12-03

nwjs - 0.100.1
Ebuild name:

dev-libs/nwjs-0.100.1

Description

Framework that lets you call all Node.js modules directly from the DOM

Added to portage

2025-12-03

nwjs - 0.104.1-r1
Ebuild name:

dev-libs/nwjs-0.104.1-r1

Description

Framework that lets you call all Node.js modules directly from the DOM

Added to portage

2025-12-03

nwjs - 0.106.0
Ebuild name:

dev-libs/nwjs-0.106.0

Description

Framework that lets you call all Node.js modules directly from the DOM

Added to portage

2025-12-03

nwjs - 0.86.0
Ebuild name:

dev-libs/nwjs-0.86.0

Description

Framework that lets you call all Node.js modules directly from the DOM

Added to portage

2025-12-03

openhab-bin - 5.0.2-r1
Ebuild name:

app-misc/openhab-bin-5.0.2-r1

Description

An open-source automation software for your home

Added to portage

2025-12-03

openhab-bin - 5.0.3-r1
Ebuild name:

app-misc/openhab-bin-5.0.3-r1

Description

An open-source automation software for your home

Added to portage

2025-12-03

pecl-mongodb - 1.16.2-r1
Ebuild name:

dev-php/pecl-mongodb-1.16.2-r1

Description

MongoDB database driver for PHP

Added to portage

2025-12-03

php-mode - 9999
Ebuild name:

app-emacs/php-mode-9999

Description

GNU Emacs major mode for editing PHP code

Added to portage

2025-12-03

pinentry - 0.1_p20250408
Ebuild name:

app-emacs/pinentry-0.1_p20250408

Description

GnuPG Pinentry server implementation for Emacs

Added to portage

2025-12-03

pkg-info - 0.6
Ebuild name:

app-emacs/pkg-info-0.6

Description

Provide information about Emacs packages

Added to portage

2025-12-03

planner - 3.42-r1
Ebuild name:

app-emacs/planner-3.42-r1

Description

Maintain a local Wiki using Emacs-friendly markup

Added to portage

2025-12-03

popcorntime-bin - 0.5.1-r2
Ebuild name:

media-video/popcorntime-bin-0.5.1-r2

Description

BitTorrent client that includes an integrated media player

Added to portage

2025-12-03

psycopg - 3.3.1
Ebuild name:

dev-python/psycopg-3.3.1

Description

PostgreSQL database adapter for Python

Added to portage

2025-12-03

pydyf - 0.12.1
Ebuild name:

dev-python/pydyf-0.12.1

Description

A low-level PDF generator

Added to portage

2025-12-03

pymongo - 4.15.5
Ebuild name:

dev-python/pymongo-4.15.5

Description

Python driver for MongoDB

Added to portage

2025-12-03

pyside - 6.10.1-r1
Ebuild name:

dev-python/pyside-6.10.1-r1

Description

Python bindings for the Qt framework

Added to portage

2025-12-03

pytest-httpx - 0.36.0
Ebuild name:

dev-python/pytest-httpx-0.36.0

Description

Send responses to HTTPX using pytest

Added to portage

2025-12-03

python - 0.3.13.10
Ebuild name:

dev-lang/python-0.3.13.10

Description

Freethreading (no-GIL) version of Python programming language

Added to portage

2025-12-03

python - 0.3.14.1
Ebuild name:

dev-lang/python-0.3.14.1

Description

Freethreading (no-GIL) version of Python programming language

Added to portage

2025-12-03

python - 3.13.10
Ebuild name:

dev-lang/python-3.13.10

Description

An interpreted, interactive, object-oriented programming language

Added to portage

2025-12-03

python - 3.14.1
Ebuild name:

dev-lang/python-3.14.1

Description

An interpreted, interactive, object-oriented programming language

Added to portage

2025-12-03

python-tests - 0.3.13.10
Ebuild name:

dev-python/python-tests-0.3.13.10

Description

Test modules from dev-lang/python

Added to portage

2025-12-03

python-tests - 0.3.14.1
Ebuild name:

dev-python/python-tests-0.3.14.1

Description

Test modules from dev-lang/python

Added to portage

2025-12-03

python-tests - 3.13.10
Ebuild name:

dev-python/python-tests-3.13.10

Description

Test modules from dev-lang/python

Added to portage

2025-12-03

python-tests - 3.14.1
Ebuild name:

dev-python/python-tests-3.14.1

Description

Test modules from dev-lang/python

Added to portage

2025-12-03

pyzotero - 1.7.6
Ebuild name:

dev-python/pyzotero-1.7.6

Description

A Python client for the Zotero API

Added to portage

2025-12-03

roundcube - 1.7_beta2
Ebuild name:

mail-client/roundcube-1.7_beta2

Description

A browser-based multilingual IMAP client with an application-like u

Added to portage

2025-12-03

ruff - 0.14.7
Ebuild name:

dev-util/ruff-0.14.7

Description

An extremely fast Python linter, written in Rust

Added to portage

2025-12-03

sabctools - 9.0.0
Ebuild name:

dev-python/sabctools-9.0.0

Description

Module providing raw yEnc encoding/decoding for SABnzbd

Added to portage

2025-12-03

safetensors - 0.7.0
Ebuild name:

sci-ml/safetensors-0.7.0

Description

Simple, safe way to store and distribute tensors

Added to portage

2025-12-03

sphinx-gallery - 0.20.0
Ebuild name:

dev-python/sphinx-gallery-0.20.0

Description

Sphinx extension to automatically generate an examples gallery

Added to portage

2025-12-03

sqlglot - 28.1.0
Ebuild name:

dev-python/sqlglot-28.1.0

Description

An easily customizable SQL parser and transpiler

Added to portage

2025-12-03

sybil - 9.3.0
Ebuild name:

dev-python/sybil-9.3.0

Description

Automated testing for the examples in your documentation

Added to portage

2025-12-03

syncthing - 2.0.12
Ebuild name:

net-p2p/syncthing-2.0.12

Description

Open Source Continuous File Synchronization

Added to portage

2025-12-03

tmuxp - 1.59.0
Ebuild name:

app-misc/tmuxp-1.59.0

Description

tmux session manager. built on libtmux

Added to portage

2025-12-03

urwid - 3.0.4
Ebuild name:

dev-python/urwid-3.0.4

Description

Curses-based user interface library for Python

Added to portage

2025-12-03

uv - 0.9.15
Ebuild name:

dev-python/uv-0.9.15

Description

A Python package installer and resolver, written in Rust

Added to portage

2025-12-03

uv-build - 0.9.15
Ebuild name:

dev-python/uv-build-0.9.15

Description

PEP517 uv build backend

Added to portage

2025-12-03

weasyprint - 67.0
Ebuild name:

dev-python/weasyprint-67.0

Description

Visual rendering engine for HTML and CSS that can export to PDF

Added to portage

2025-12-03

wordpress - 6.9
Ebuild name:

www-apps/wordpress-6.9

Description

Wordpress PHP and MySQL based content management system (CMS)

Added to portage

2025-12-03

xkbcomp - 1.5.0
Ebuild name:

x11-apps/xkbcomp-1.5.0

Description

XKB keyboard description compiler

Added to portage

2025-12-03

zlib-ng - 2.3.2
Ebuild name:

sys-libs/zlib-ng-2.3.2

Description

Fork of the zlib data compression library

Added to portage

2025-12-03

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