Skip to content

Commit 1c924bd

Browse files
committed
Added site-to-site example
1 parent 9a1bd89 commit 1c924bd

File tree

6 files changed

+163
-1
lines changed

6 files changed

+163
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Changed fs structure
66
- Rewritten helper scripts
77
- Reorganized examples
8+
- Added Site-to-site example
89

910
### 2.0.6 - Fixed bugs, added additonal parameters
1011

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ LABEL org.opencontainers.image.title="OpenVPN Server" \
3131
#
3232
ENV BACKUP_DIR=/config/backup \
3333
EASYRSA=/usr/share/easy-rsa \
34+
EASYRSA_EXT_DIR=/config/x509-types \
3435
EASYRSA_PKI=/config/pki \
3536
EASYRSA_SSL_CONF=/config/openssl-easyrsa.cnf \
3637
EASYRSA_SAFE_CONF=/config/safessl-easyrsa.cnf \
@@ -41,6 +42,7 @@ ENV BACKUP_DIR=/config/backup \
4142
RUN apk add --no-cache \
4243
# Core packages
4344
bash \
45+
gettext \
4446
easy-rsa \
4547
iptables \
4648
ip6tables \
@@ -74,7 +76,8 @@ RUN apk add --no-cache \
7476
>> /etc/sudoers.d/${CONTAINER_USER} && \
7577
# Default configuration
7678
cp $EASYRSA/vars.example /defaults/vars && \
77-
cp $EASYRSA/openssl-easyrsa.cnf /defaults
79+
cp $EASYRSA/openssl-easyrsa.cnf /defaults && \
80+
cp -r $EASYRSA/x509-types /defaults
7881

7982
# Add repo files to image
8083
COPY root/ /
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# basic_s2s
2+
3+
Features:
4+
5+
- Site-to-site VPN
6+
7+
## Configuration
8+
9+
``` bash
10+
# PKI init
11+
ovpn pki init [nopass]
12+
13+
# Load example
14+
ovpn example basic_s2s
15+
16+
# Certifcates
17+
# NOTE: To also use server certificates for p2p connection between servers
18+
# add clientAuth to extendedKeyUsage before generating certificate
19+
ovpn subject add first server [nopass]
20+
# Change filenames in config file
21+
22+
ovpn subject add second server [nopass]
23+
ovpn subject gen-pkg second # creates .tar.gz in client-confs
24+
# Copy .tar.gz to second machine
25+
ovpn load NAME.pkg.tar.gz # Second machine
26+
```
27+
28+
## External docs
29+
30+
- [Tutorial 1](https://zeldor.biz/2010/12/openvpn-site-to-site-setup/)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#
2+
# Basic OpenVPN site-to-site configuration
3+
# @author Martin Dagarin
4+
# @version 1
5+
# @since 21/03/2020
6+
#
7+
8+
mode p2p
9+
dev tun0
10+
config include.conf
11+
config unprivileged.conf
12+
13+
# Basic info
14+
remote $REMOTE_A
15+
proto $PROTO
16+
port $PORT
17+
18+
# Network info
19+
ifconfig $IP_B $IP_A
20+
21+
# Set routes in routing table
22+
# route 192.168.2.0 255.255.255.0
23+
24+
# CA files
25+
tls-client
26+
remote-cert-tls server
27+
28+
# Connection settings
29+
persist-local-ip
30+
persist-remote-ip
31+
persist-tun
32+
33+
# Encryption settings
34+
cipher AES-256-GCM
35+
36+
# Additional settings
37+
keepalive 15 120
38+
explicit-exit-notify 10
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#
2+
# Basic OpenVPN site-to-site configuration
3+
# @author Martin Dagarin
4+
# @version 1
5+
# @since 21/03/2020
6+
#
7+
8+
mode p2p
9+
dev tun0
10+
config include.conf
11+
config unprivileged.conf
12+
13+
# Basic info
14+
remote $REMOTE_B
15+
proto $PROTO
16+
port $PORT
17+
18+
# Network info
19+
ifconfig $IP_A $IP_B
20+
21+
# Set routes in routing table
22+
# route 192.168.2.0 255.255.255.0
23+
24+
# CA files
25+
ca ca.crt
26+
cert server.crt
27+
key server.key
28+
dh dh.pem
29+
tls-crypt ta.key
30+
tls-server # Note: Only for TLS negotiation, requires dh.pem
31+
remote-cert-tls client # NOTE: Change this to server if you use server certificates on both sides
32+
33+
# Connection settings
34+
persist-local-ip
35+
persist-remote-ip
36+
persist-tun
37+
38+
# Encryption settings
39+
cipher AES-256-GCM
40+
41+
# Additional settings
42+
keepalive 15 120
43+
explicit-exit-notify 10
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/with-contenv bash
2+
#
3+
# Config wizard for basic_s2s example
4+
# @author Martin Dagarin
5+
# @version 1
6+
# @since 20/03/2020
7+
#
8+
9+
if [ -z "$1" ]; then
10+
echo 'Directory path missing'
11+
exit 1
12+
fi
13+
14+
read -p 'Protocol udp, tcp, udp6, tcp6 [udp]: ' protocol
15+
protocol=${protocol:=udp}
16+
17+
read -p 'Port [1194]: ' port
18+
port=${port:=1194}
19+
20+
read -p 'Site A public IP: ' remote_a
21+
if [ -z "$remote_a" ]; then echo 'Invalid IP'; exit 2; fi
22+
23+
read -p 'Site A tunnel IP: ' ip_a
24+
if [ -z "$ip_a" ]; then echo 'Invalid IP'; exit 2; fi
25+
26+
read -p 'Site B public IP: ' remote_b
27+
if [ -z "$remote_b" ]; then echo 'Invalid IP'; exit 2; fi
28+
29+
read -p 'Site B tunnel IP: ' ip_b
30+
if [ -z "$ip_b" ]; then echo 'Invalid IP'; exit 2; fi
31+
32+
confs=(
33+
"$1/config/openvpn/openvpn.conf"
34+
"$1/config/openvpn/openvpn-template.conf"
35+
)
36+
37+
for file in "${confs[@]}"
38+
do
39+
mv $file $file.old
40+
PROTO="$protocol" \
41+
PORT="$port" \
42+
REMOTE_A="$remote_a" \
43+
IP_A="$ip_a" \
44+
REMOTE_B="$remote_b" \
45+
IP_B="$ip_b" \
46+
envsubst < $file.old > $file
47+
done

0 commit comments

Comments
 (0)