While it looks hackish, I don't think there's a better way (in Bash) to open
the /dev/net/tun character device.
Checking for presence of /dev/net/tun like were doing is not good enough.
nf_tables is not available in old OpenVZ kernels, so we need to use
iptables-legacy instead.
This issue only affects Debian 10 as it is the only distribution using iptables
with a nf_tables backend by default.
This is supposedly resolved in the newest kernels: https://bit.ly/3fgNZCh
Additionally, a bugfix for the ip6tables path is also included.
New logic makes way more sense:
- If either firewalld or iptables are present, use whatever we have
- If not, install firewalld in CentOS/Fedora and iptables in Debian/Ubuntu
- Use a checkip service which works fine over HTTP to avoid issues in systems
where ca-certificates is not available
- Increase timeout to 10 seconds, because the new service is a bit slower from
some locations
- Improve grep sanitization
- Fix#694: added sanitization during the public IP address configuration and
switch to AWS checkip since the Akamai service doesn't support HTTPS.
- Add validation to cover an unlikely case where: server is behind NAT,
checkip service is unreachable and user doesn't provide input when asked for
the public IP address or hostname.
- Other small improvements not worth describing in detail.
LowEndSpirit fixed the issue on their end, so this is longer needed.
Additionally, the check causes unneeded trouble for users whose system doesn't
have the iptables package installed.
This commit contains lots changes which are not very significant on its own but
provide important usability improvements and future proofing.
It also includes changes which required OpenVPN v2.4+ and were pending until
that version became widely available.
- General cleanup
- Improved IP address and NAT configuration
- Added input validation and sanitization
- Fix#603
- Remove "sndbuf" and "recvbuf" parameters
- Add server-side "explicit-exit-notify"
- Switch from "setenv opt" to "ignore-unknown-option"
- Switch from "tls-auth" to "tls-crypt"
- Other minor bugfixes and optimizations
OpenVPN 2.4 packages provide a new systemd service unit which uses a different
directory structure. This commit drops support for Ubuntu 16.04 which has v2.3
packages.
- SELinux in CentOS already has rules for both udp/1194 and tcp/1194,
so the protocol check was not needed.
- Remove unneeded arguments from some grep and rm commands.