Skip to content

Commit ae8801e

Browse files
committed
Added no firewall modification option
Added no firewall modification option to be able to disable iptables alteration
1 parent e988437 commit ae8801e

File tree

16 files changed

+126
-6
lines changed

16 files changed

+126
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Changelog
22

3-
### 1.0.5 - Bugfix, finish hook
3+
### 1.0.5 - Bugfix, finish hook, persistent interface, no firewall
44

55
- Fixed bug when running hooks (#3)
66
- Added **finish** hook (which runs just before container exit)
77
- Added **persistent interface** option, so interface is persistently present on device (if using host networking mode) and firewall setup rules are executed **only once** (no ip tables mess) (#1)
88
- Logging chaned to stdout, no more log file by default
9+
- Added **firewall disable** feature to disable all firewall related modifications
910

1011
### 1.0.4 - IPv6 docs, improved wizards
1112

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ services:
7070
|:-----------:|:----------:|
7171
|`-e PUID=1000`|for UserID - see below for explanation|
7272
|`-e PGID=1000`|for GroupID - see below for explanation|
73-
|`-o OVPN_PERINT=false`|Disable persistent TUN interface|
73+
|`-e OVPN_NFW=true`|Disable any firewall related rules to be created, modified ... (must be implemented in example)|
74+
|`-e OVPN_PERINT=false`|Disable persistent TUN interface|
7475
|`-v /config`|All the config files including OpenVPNs reside here|
7576

7677
See also: [EasyRSA](https://github.com/OpenVPN/easy-rsa/blob/master/doc/EasyRSA-Advanced.md)
@@ -147,7 +148,6 @@ For more infromation see:
147148

148149
- [OpenVPN troubleshoot guide](https://community.openvpn.net/openvpn/wiki/HOWTO#Troubleshooting)
149150

150-
151151
## Contribute
152152

153153
Feel free to contribute new features to this container, but first see [Contribute Guide](CONTRIBUTING.md).
@@ -159,7 +159,7 @@ Planed features:
159159
Wanted features (please help implement):
160160

161161
- LDAP authentication script
162-
- Google authenticator
162+
- Google authenticator
163163

164164
## Licenses
165165

@@ -168,7 +168,6 @@ Wanted features (please help implement):
168168
- [Base image](https://github.com/linuxserver/docker-baseimage-alpine)
169169
- [s6 Layer](https://github.com/just-containers/s6-overlay/blob/master/LICENSE.md)
170170

171-
172171
## Versions
173172

174173
See [CHANGELOG](CHANGELOG.md)

root/app/lib/settings

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ function intPersistant() {
1616
fi
1717
}
1818

19+
#
20+
# Checks if we use firewall rules
21+
# @return 1 if yes, 0 if not
22+
#
23+
function useFW() {
24+
if [ ! -n "$OVPN_NFW" ] || ([ "$OVPN_NFW" != "true" ] && [ "$OVPN_NFW" != "1" ]); then
25+
return 1 # yes by default
26+
else
27+
return 0 # No
28+
fi
29+
}
30+
1931
#
2032
# Checks if TUN interface exists already
2133
# @return 0 if found, 1 if not found

root/defaults/example/README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,30 @@ config
3535
Readme.md # Info about example, what to configure
3636
```
3737

38+
### Hooks
39+
40+
- start hook file with
41+
42+
``` bash
43+
#!/usr/bin/with-contenv bash
44+
45+
source /app/lib/settings
46+
source /app/lib/utils
47+
```
48+
49+
- if hooks call any **firewall** related commands add after above code and before any commands
50+
51+
``` bash
52+
# Check if firewall rules are disabled
53+
useFW
54+
if [ $? -eq 0 ]; then
55+
# Don't use fw rules
56+
exit 0
57+
fi
58+
```
59+
60+
- also check the examples how persistent interface is handled, so you don't create iptables mess (running init, up script once, never call down, finish)
61+
3862
### Notes
3963
4064
- **DO NOT** use `dev` attribute, because it is set to static interface `tun0`.
@@ -50,7 +74,7 @@ User will call `ovpn_enconf CONFIG_NAME [wizard args]` to load your example in s
5074
5175
Then there are two options:
5276
53-
1. User manualy configure settigns in `/config/openvpn` folder
77+
1. User manualy configure settings in `/config/openvpn` folder
5478
2. Your **wizard** script, configures files which will be copied to `/config/openvpn`
5579
- Configuration files are copied to temporary location (so they can be modified)
5680
- `wizard` script will be called with temporary location as first argument `$1` (folder has same structure as in examples)

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
source /app/lib/settings
44
source /app/lib/utils
55

6+
# Check if firewall rules are disabled
7+
useFW
8+
if [ $? -eq 0 ]; then
9+
# Don't use fw rules
10+
exit 0
11+
fi
12+
613
# Don't run if interface persistent
714
intPersistant
815
if [ $? -eq 1 ]; then

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
source /app/lib/settings
44
source /app/lib/utils
55

6+
# Check if firewall rules are disabled
7+
useFW
8+
if [ $? -eq 0 ]; then
9+
# Don't use fw rules
10+
exit 0
11+
fi
12+
613
# Don't run if interface persistent
714
intPersistant
815
if [ $? -eq 1 ]; then

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
source /app/lib/settings
44
source /app/lib/utils
55

6+
# Check if firewall rules are disabled
7+
useFW
8+
if [ $? -eq 0 ]; then
9+
# Don't use fw rules
10+
exit 0
11+
fi
12+
613
# Run only once if interface persistent
714
intPersistant
815
if [ $? -eq 1 ]; then

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
source /app/lib/settings
44
source /app/lib/utils
55

6+
# Check if firewall rules are disabled
7+
useFW
8+
if [ $? -eq 0 ]; then
9+
# Don't use fw rules
10+
exit 0
11+
fi
12+
613
# Run only once if interface persistent
714
intPersistant
815
if [ $? -eq 1 ]; then

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
source /app/lib/settings
44
source /app/lib/utils
55

6+
# Check if firewall rules are disabled
7+
useFW
8+
if [ $? -eq 0 ]; then
9+
# Don't use fw rules
10+
exit 0
11+
fi
12+
613
# Don't run if interface persistent
714
intPersistant
815
if [ $? -eq 1 ]; then

root/defaults/example/config/basic_nat_wlp/hooks/finish/10-network.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
source /app/lib/settings
44
source /app/lib/utils
55

6+
# Check if firewall rules are disabled
7+
useFW
8+
if [ $? -eq 0 ]; then
9+
# Don't use fw rules
10+
exit 0
11+
fi
12+
613
# Don't run if interface persistent
714
intPersistant
815
if [ $? -eq 1 ]; then

0 commit comments

Comments
 (0)