0

For days i have searched for an answer regarding an issue with OpenVPN. I made a VPN with my raspberry pi running raspbian. When i connect to the VPN, my IP address changes but i cannot connect to the internet. I have tried on Windows 10, an iPhone, and a Galaxy s7. My Raspberry Pi is connected to the router directly with an Ethernet cable.

All devices connect to the VPN but eventually say, "This site can't be reached. [URL]'s server DNS address could not be found "

I know that there are tons of support pages already out there about this but i have tried everything with no success. Listed below are the files if you need them.

/etc/openvpn/server.conf:

local 192.168.1.103
dev tun
proto udp
port 1194
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/RaspberryVPN.crt
key /etc/openvpn/easy-rsa/keys/RaspberryVPN.key
dh /etc/openvpn/easy-rsa/keys/dh1024.pem 
server 10.8.0.0 255.255.255.0
ifconfig 10.8.0.1 10.8.0.2
push "route 10.8.0.1 255.255.255.255"
push "route 10.8.0.0 255.255.255.0"
push "route 192.168.1.103 255.255.255.0"
push "dhcp-option DNS 8.8.8.8"
client-to-client
push "redirect-gateway def1"
duplicate-cn
keepalive 10 120
tls-auth /etc/openvpn/easy-rsa/keys/ta.key 0
cipher AES-128-CBC
comp-lzo
user nobody
group nogroup
persist-key
persist-tun
status /var/log/openvpn-status.log 20
log /var/log/openvpn.log
verb 1

/etc/firewall-openvpn-rules.sh:

#!/bin/sh

#iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j SNAT --to-source 192.168.1.103
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE

/etc/network/interfaces:

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet static
address 192.168.1.103
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
        pre-up /etc/firewall-openvpn-rules.sh

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

/etc/openvpn/easy-rsa/keys/Default.txt:

client
dev tun
proto udp
remote [EXTERNAL IP] 1194
resolv-retry infinite
nobind
persist-key
persist-tun
mute-replay-warnings
ns-cert-type server
key-direction 1
cipher AES-128-CBC
comp-lzo
verb 1
mute 20

/etc/sysctl.conf:

net.ipv4.ip_forward=1
2
  • I did just realize that originally i put my internal IP on the line that says, "remote [EXTERNAL IP] 1194" in the file, Default.txt. I fixed it in the defaults and i used Notepad++ to change that line to the correct information but it still failed.
    – Zach S
    Jul 20, 2017 at 20:48
  • When i connect to OpenVPN it says, "Traffic: 6.1 KB in, 66.9 KB out". Is my connection issue caused by the slow speed or because of something else
    – Zach S
    Jul 20, 2017 at 21:03

3 Answers 3

0

Have you enabled packet forwarding on the Pi?

You need to edit the /etc/sysctl.conf file and ensure the following value is set to 1 (as here) - and make sure it's not commented-out either:

net.ipv4.ip_forward=1

Hopefully that might help. I can't immediately spot any problems with your config above.

1
  • yes i have. i meant to add that to the list of files. Thanks for the reply though
    – Zach S
    Jul 20, 2017 at 20:43
0

Have you ensured your interfaces are up? Try running

sudo ifconfig <interface> down
sudo ifconfig <interface> up

Also you seem to be using Google's DNS, you could try using another provider, such as Freenom's DNS (80.80.80.80, 80.80.81.81) or the OpenNIC DNS (87.98.175.85) Other than that, I can't think of anything else, if nothing works, you could just have to start again, back at square one.

4
  • im very new to this. What is an example of the text that replaces '<interface>'
    – Zach S
    Jul 20, 2017 at 20:44
  • Sorry, as you are on Ethernet, the interface would most likely be eth0, on wireless it would be wlan0 Jul 20, 2017 at 20:45
  • Also, ive gone to my router settings and found DNS1 and DNS2 and tried to make them the DNS's. That failed. Ive also tried making it 192.168.1.1 or 192.168.1.0 like all of the tutorials but that also failed.
    – Zach S
    Jul 20, 2017 at 20:56
  • I changed my DNS with no luck... The commands dont work either.
    – Zach S
    Jul 20, 2017 at 21:10
0

So i just reset my SD card and started all the way over but i used PiVPN this time. It was simple and set it up quickly. Below are the files that PiVPN set up. Some files that were listed in the question were not created with PiVPN. PiVPN Site

/etc/openvpn/server.conf:

push "route 192.168.1.0 255.255.255.0"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
push "redirect-gateway def1"
client-to-client
duplicate-cn
keepalive 10 120
tls-version-min 1.2
tls-auth /etc/openvpn/easy-rsa/pki/ta.key 0
cipher AES-256-CBC
auth SHA256
comp-lzo
user nobody
group nogroup
persist-key
persist-tun
#crl-verify /etc/openvpn/crl.pem
status /var/log/openvpn-status.log 20
status-version 3
log /var/log/openvpn.log
verb 1
# Generated for use by PiVPN.io

/etc/network/interfaces:

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

/etc/sysctl.conf:

net.ipv4.ip_forward=1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .