I'm setting up an OpenVPN server and its related client, to use as a networking bridge from my client to the internet (precisely to a specific IP but that's a future step).
I'm using TUN mode as it seemed easier and I did not need BRIDGE specificities.
I read carefully the complete How To (https://openvpn.net/community-resources/how-to/).
My issue is that I cannot manage to make, on my server, my incoming VPN trafic go outside of the private subnet of the VPN.
I tried routing a specific IP through the VPN as it's my final goal, but I'm already first trying following the documentation and routing all internet traffic following the "Routing all client traffic (including web-traffic) through the VPN" section of the How-To.
When connected to the VPN, I cannot ping a single address that is not in the 10.8.0.0/24 subnet.
I'm using Ubuntu 22.04 LTS, fresh install, and I disabled ufw to try not interfering with my setup
Here are my configuration files
Code: Select all
# OPENVPN SERVER CONFIG
port 38330
proto udp
dev tun
ca OBFUSCATED.DOMAIN.NAME_ca.crt
cert OBFUSCATED.DOMAIN.NAME_openvpnserver.crt
key OBFUSCATED.DOMAIN.NAME_openvpnserver.key
dh OBFUSCATED.DOMAIN.NAME_openvpnserver_dh2048.pem
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist /var/log/openvpn/ipp.txt
;push "route OBFUSCATED.REMOTE.SERVER.IP" # Commented this one out until I fix routing
push "redirect-gateway def1"
push "dhcp-option DNS 10.8.0.1"
keepalive 10 120
tls-auth OBFUSCATED.DOMAIN.NAME_openvpnserver_ta.key 0
cipher AES-256-CBC
persist-key
persist-tun
status /var/log/openvpn/openvpn-status.log
log-append /var/log/openvpn/openvpn.log
verb 4
explicit-exit-notify 1
Code: Select all
# OPENVPN CLIENT CONFIG
client
dev tun
proto udp
remote OBFUSCATED.OPENVPN.SERVER.IP 38330
resolv-retry infinite
nobind
persist-key
persist-tun
ca OBFUSCATED.DOMAIN.NAME_ca.crt
cert OBFUSCATED.DOMAIN.NAME_openvpnclient.crt
key OBFUSCATED.DOMAIN.NAME_openvpnclient.key
tls-auth OBFUSCATED.DOMAIN.NAME_openvpnserver_ta.key 1
cipher AES-256-CBC
verb 3
mute 20
Code: Select all
# iptables command I ran
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o enp1s0f0 -j MASQUERADE
Code: Select all
# "iptables -L -t nat" result
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- 10.8.0.0/24 anywhere
Code: Select all
# "ip addr" result
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp1s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether ob:fu:sc:at:ed:ma brd ff:ff:ff:ff:ff:ff
inet OBFUSCATED.OPENVPN.SERVER.IP/24 metric 100 brd OBFUSCATED.SERVER.SUBNET.IP scope global dynamic enp1s0f0
valid_lft 49136sec preferred_lft 49136sec
inet6 2001:41d0:403:5e25::/56 scope global
valid_lft forever preferred_lft forever
inet6 fe80::d250:99ff:fedb:ee43/64 scope link
valid_lft forever preferred_lft forever
3: enp1s0f1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether ob:fu:sc:at:ed:ma brd ff:ff:ff:ff:ff:ff
5: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 500
link/none
inet 10.8.0.1 peer 10.8.0.2/32 scope global tun0
valid_lft forever preferred_lft forever
inet6 fe80::4d29:3ebf:c41b:2ebf/64 scope link stable-privacy
valid_lft forever preferred_lft forever
Code: Select all
# "iptables -L" global result
Chain INPUT (policy ACCEPT)
target prot opt source destination
ufw-before-logging-input all -- anywhere anywhere
ufw-after-input all -- anywhere anywhere
ufw-after-logging-input all -- anywhere anywhere
ufw-reject-input all -- anywhere anywhere
ufw-track-input all -- anywhere anywhere
LOG all -- 10.8.0.0/24 anywhere LOG level warning
LOG all -- anywhere anywhere LOG level warning
Chain FORWARD (policy ACCEPT)
target prot opt source destination
ufw-before-logging-forward all -- anywhere anywhere
ufw-before-forward all -- anywhere anywhere
ufw-after-forward all -- anywhere anywhere
ufw-after-logging-forward all -- anywhere anywhere
ufw-reject-forward all -- anywhere anywhere
ufw-track-forward all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ufw-before-logging-output all -- anywhere anywhere
ufw-before-output all -- anywhere anywhere
ufw-after-output all -- anywhere anywhere
ufw-after-logging-output all -- anywhere anywhere
ufw-reject-output all -- anywhere anywhere
ufw-track-output all -- anywhere anywhere
Chain ufw-after-forward (1 references)
target prot opt source destination
Chain ufw-after-input (1 references)
target prot opt source destination
Chain ufw-after-logging-forward (1 references)
target prot opt source destination
Chain ufw-after-logging-input (1 references)
target prot opt source destination
Chain ufw-after-logging-output (1 references)
target prot opt source destination
Chain ufw-after-output (1 references)
target prot opt source destination
Chain ufw-before-forward (1 references)
target prot opt source destination
Chain ufw-before-input (0 references)
target prot opt source destination
Chain ufw-before-logging-forward (1 references)
target prot opt source destination
Chain ufw-before-logging-input (1 references)
target prot opt source destination
Chain ufw-before-logging-output (1 references)
target prot opt source destination
Chain ufw-before-output (1 references)
target prot opt source destination
Chain ufw-reject-forward (1 references)
target prot opt source destination
Chain ufw-reject-input (1 references)
target prot opt source destination
Chain ufw-reject-output (1 references)
target prot opt source destination
Chain ufw-track-forward (1 references)
target prot opt source destination
Chain ufw-track-input (1 references)
target prot opt source destination
Chain ufw-track-output (1 references)
target prot opt source destination
Thank you for your help, I'm available for any suggestions or need of more info.
Manuel.