Skip to content

Commit 1a4be14

Browse files
committed
Merge branch 'develop'
2 parents 97232dd + 3c118c3 commit 1a4be14

File tree

24 files changed

+594
-6
lines changed

24 files changed

+594
-6
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
### 1.0.3 - New examples, fixes, more docs
4+
5+
- Updated instructions
6+
- Improved `Makefile`
7+
- Allowed **ping** to the container
8+
- Added new examples **basic_nat_wlp** and **basic_routed**
9+
- Added **LAN protection** to original example
10+
- Added **docker-compose** for sample
11+
312
### 1.0.2 - Official release
413

514
- Fixed typo in `basic_nat` example config wizard

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ build:
2929
config:
3030
@echo "Running temporary container"
3131
mkdir -p data
32-
docker run -it --rm --cap-add NET_ADMIN -v ${DATA_DIR}:/config ${IMAGE_NAME}:latest bash
32+
docker run -it -e PUID=$(id -u) -e PGID=$(id -g) --rm --cap-add NET_ADMIN -v ${DATA_DIR}:/config ${IMAGE_NAME}:latest bash
3333

3434
#
3535
# Setups & starts real container
3636
# Run only once, then use docker start|stop|restart|exec
3737
#
3838
setup:
3939
@echo "Running temporary container"
40-
docker run -it --cap-add NET_ADMIN -p 1194:1194/udp -v ${DATA_DIR}:/config --name ${CONTAINER_NAME} ${IMAGE_NAME}:latest
40+
docker run -it -d -e PUID=$(id -u) -e PGID=$(id -g) --cap-add NET_ADMIN -p 1194:1194/udp -v ${DATA_DIR}:/config --name ${CONTAINER_NAME} ${IMAGE_NAME}:latest
4141

4242
#
4343
# Starts container

README.md

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,37 @@ docker run \
3434

3535
### docker-compose
3636

37-
```
38-
37+
``` yml
38+
version: '2.2'
39+
services:
40+
ovpn:
41+
image: slocomptech/openvpn
42+
container_name: ovpn
43+
hostname: ovpn
44+
cap_add:
45+
- NET_ADMIN
46+
ports:
47+
- "1194:1194/udp"
48+
volumes:
49+
- ./data:/config
50+
environment:
51+
- PUID=1000
52+
- PGUID=1000
53+
restart: on-failure
54+
# If you want to build from source add build:
55+
build:
56+
context: .
57+
cache_from:
58+
- lsiobase/alpine.python3:latest
59+
networks:
60+
mynetwork:
61+
ipv4_address: 10.0.0.5
62+
ipv6_address: 2001:1111::5
63+
64+
networks:
65+
mynetwork:
66+
driver: host
67+
enable_ipv6: true
3968
```
4069
4170
## Parameters
@@ -112,6 +141,11 @@ For more infromation see:
112141
- **configuration example directory** (for more info about example)
113142
- [Contributing](CONTRIBUTING.md) (for explanation how container works, how to write an example config ...)
114143

144+
## Troubleshooting
145+
146+
- [OpenVPN troubleshoot guide](https://community.openvpn.net/openvpn/wiki/HOWTO#Troubleshooting)
147+
148+
115149
## Contribute
116150

117151
Feel free to contribute new features to this container, but first see [Contribute Guide](CONTRIBUTING.md).
@@ -128,7 +162,7 @@ Wanted features (please help implement):
128162
## Licenses
129163

130164
- [This project](LICENSE.md)
131-
- [OpenVPN]()
165+
- [OpenVPN](https://openvpn.net/terms/)
132166
- [Base image](https://github.com/linuxserver/docker-baseimage-alpine)
133167
- [s6 Layer](https://github.com/just-containers/s6-overlay/blob/master/LICENSE.md)
134168

docker-compose.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#
2+
# OpenVPN server sample configuration
3+
#
4+
5+
version: '2.2'
6+
services:
7+
ovpn:
8+
image: slocomptech/openvpn
9+
container_name: ovpn
10+
hostname: ovpn
11+
cap_add:
12+
- NET_ADMIN
13+
ports:
14+
- "1194:1194/udp"
15+
volumes:
16+
- ./data:/config
17+
#environment:
18+
# - PUID=1000
19+
# - PGUID=1000
20+
restart: on-failure
21+
build:
22+
context: .
23+
cache_from:
24+
- lsiobase/alpine.python3:latest
25+
26+
network_mode: "bridge"
27+
#network_mode: "host"
28+

root/defaults/example/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,6 @@ Hooks are located in `hook` directory. Please follow hook guidelines:
6767
- At the top of the script
6868
- Optionaly copyright notice
6969
- What this hook does
70-
- Setttings with comments and an example settings values
70+
- Setttings with comments and an example settings values
71+
72+
**Note:** All hooks run as non-root user so instead of using `ip` and `iptables` use `ovpn-ip` and `ovpn-iptables`.

root/defaults/example/config/basic_nat/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Features:
55
- Works out of the box on bridge or host network
66
- NAT (Network translation protocol)
77
- Has configuration wizard
8+
- LAN protection (does not allow traffic to LANs connected to server)
89

910
## Configure
1011

root/defaults/example/config/basic_nat/hooks/down/10-network.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
# Close OpenVPN port to outside
88
ovpn-iptables -D INPUT -p udp -m udp --dport $PORT -j ACCEPT -m comment --comment "Open OpenVPN port"
99

10+
# Disable LAN protection of VPN
11+
ovpn-iptables -D FORWARD -i tun0 -s $NETWORK_ADDRESS/24 -o eth0 -d 10.0.0.0/8 -j REJECT -m comment --comment "Drop traffic VPN --> LANs"
12+
ovpn-iptables -D FORWARD -i tun0 -s $NETWORK_ADDRESS/24 -o eth0 -d 192.168.0.0/16 -j REJECT -m comment --comment "Drop traffic VPN --> LANs"
13+
ovpn-iptables -D FORWARD -i tun0 -s $NETWORK_ADDRESS/24 -o eth0 -d 172.16.0.0/12 -j REJECT -m comment --comment "Drop traffic VPN --> LANs"
14+
1015
# Disable Routing Internet <--> VPN network
1116
ovpn-iptables -D FORWARD -i tun0 -s $NETWORK_ADDRESS/24 -o eth0 -j ACCEPT -m comment --comment "Allow traffic VPN --> Internet"
1217
ovpn-iptables -D FORWARD -i eth0 -d $NETWORK_ADDRESS/24 -o tun0 -j ACCEPT -m comment --comment "Allow traffic Internet --> VPN"

root/defaults/example/config/basic_nat/hooks/init/10-network.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@ ovpn-iptables -P INPUT DROP
1515
# Allow established connection
1616
ovpn-iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT -m comment --comment "Accept traffic from established connections"
1717

18+
# Allow ICMP ping request
19+
ovpn-iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT
20+
1821
# Drop all forwarded traffic
1922
ovpn-iptables -P FORWARD DROP

root/defaults/example/config/basic_nat/hooks/up/10-network.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
# Open OpenVPN port to outside
88
ovpn-iptables -A INPUT -p udp -m udp --dport $PORT -j ACCEPT -m comment --comment "Open OpenVPN port"
99

10+
# Protect LANs after VPN
11+
ovpn-iptables -A FORWARD -i tun0 -s $NETWORK_ADDRESS/24 -o eth0 -d 10.0.0.0/8 -j REJECT -m comment --comment "Drop traffic VPN --> LANs"
12+
ovpn-iptables -A FORWARD -i tun0 -s $NETWORK_ADDRESS/24 -o eth0 -d 192.168.0.0/16 -j REJECT -m comment --comment "Drop traffic VPN --> LANs"
13+
ovpn-iptables -A FORWARD -i tun0 -s $NETWORK_ADDRESS/24 -o eth0 -d 172.16.0.0/12 -j REJECT -m comment --comment "Drop traffic VPN --> LANs"
14+
1015
# Allow Routing Internet <--> VPN network
1116
ovpn-iptables -A FORWARD -i tun0 -s $NETWORK_ADDRESS/24 -o eth0 -j ACCEPT -m comment --comment "Allow traffic VPN --> Internet"
1217
ovpn-iptables -A FORWARD -i eth0 -d $NETWORK_ADDRESS/24 -o tun0 -j ACCEPT -m comment --comment "Allow traffic Internet --> VPN"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# basic_nat_wlp
2+
3+
Features:
4+
5+
- Works out of the box on bridge or host network
6+
- NAT (Network translation protocol)
7+
- Has configuration wizard
8+
- **WITHOUT** LAN protection (does not allow traffic to LANs connected to server), so you can still access devices in LAN (but **routed** example is recommended, because here traffic is still NAT-ed)
9+
10+
## Configure
11+
12+
``` bash
13+
ovpn_enconf basic_nat_wlp
14+
#Protocol udp, tcp, udp6, tcp6 [udp]:
15+
#VPN network [10.0.0.0]:
16+
#Port [1194]:
17+
#Public IP or domain of server: <PUBLIC IP>
18+
#DNS1 [8.8.8.8]:
19+
#DNS2 [8.8.4.4]:
20+
```

0 commit comments

Comments
 (0)