Hello,
I have a Raspberry Pi (IP 192.168.0.20) running inside my LAN (ADSL-Router 192.168.0.1), which is used as NAS (samba server). So from a PC and a Laptop (both Win7 64bit) I can see that shared drive when I'm inside the LAN.
Now I want to be able to connect with my Laptop to the shared drive in the same way (so that it shows up in the network environment), even via Internet when I'm away.
First thing I did was to set up a VPN server on the raspberry (
http://jankarres.de/2013/05/raspberry-pi-openvpn-vpn-server-installieren/), it worked and I could connect to Internet via my home IP (but would not see any network environment). The configuration files for the working VPN tunnel setup (using
tcp because udp did not work):
server.conf:
port 1194
proto tcp
dev tun
#dev tap0
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/server.crt
key /etc/openvpn/easy-rsa/keys/server.key
dh /etc/openvpn/easy-rsa/keys/dh1024.pem
user nobody
group nogroup
server 10.8.0.0 255.255.255.0
#server-bridge 192.168.0.20 255.255.255.0 192.168.0.128 192.168.0.254
ifconfig-pool-persist ipp.txt
persist-key
persist-tun
status /var/log/openvpn-status.log
verb 3
client-to-client
push "redirect-gateway def1 bypass-dhcp"
#set the dns servers
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
log-append /var/log/openvpn
comp-lzo
duplicate-cn
keepalive 10 120
client.conf:
dev tun
client
proto tcp
remote asdf.asdf.com 1194
resolv-retry infinte
nobind
persist-key
persist-tun
ca ca.crt
cert client1.crt
key client1.key
comp-lzo
verb3
ifconfig for the working OpenVPN tunnel setup:
pi@raspberrypi /etc/openvpn $ ifconfig
eth0 Link encap:Ethernet HWaddr b8:27:eb:f4:8b:c4
inet addr:192.168.0.20 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:21954 errors:0 dropped:0 overruns:0 frame:0
TX packets:35090 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3738095 (3.5 MiB) TX bytes:23935780 (22.8 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:62811 errors:0 dropped:0 overruns:0 frame:0
TX packets:62811 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:265883140 (253.5 MiB) TX bytes:265883140 (253.5 MiB)
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.8.0.1 P-t-P:10.8.0.2 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:198 errors:0 dropped:0 overruns:0 frame:0
TX packets:207 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:20890 (20.4 KiB) TX bytes:62885 (61.4 KiB)
So now,
to access the shared drive I wanted to create a OpenVPN bridge and followed this tutorial:
http://prssrp.blogspot.co.at/2014/02/raspberry-pi-openvpn-server-bridge-mode.html. I installed bridge-utils and created bridge-start.sh, bridge-stop.sh and bridge-firewall.sh.
bridge-start.sh:
br="br0"
tap="tap0"
eth="eth0"
eth_ip="192.168.0.20"
eth_netmask="255.255.255.0"
eth_broadcast="192.168.0.255"
for t in $tap; do
openvpn --mktun --dev $t
done
brctl addbr $br
brctl addif $br $eth
for t in $tap; do
brctl addif $br $t
done
for t in $tap; do
ifconfig $t 0.0.0.0 promisc up
done
ifconfig $eth 0.0.0.0 promisc up
ifconfig $br $eth_ip netmask $eth_netmask broadcast $eth_broadcast
bridge-stop.sh:
br="br0"
tap="tap0"
ifconfig $br down
brctl delbr $br
for t in $tap; do
openvpn --rmtun --dev $t
done
bridge-firewall.sh:
iptables -A INPUT -i tap0 -j ACCEPT
iptables -A INPUT -i br0 -j ACCEPT
iptables -A FORWARD -i br0 -j ACCEPT
In server.conf I change then
dev tun
to
dev tap0
and replace
server 10.8.0.0 255.255.255.0
with
server-bridge 192.168.0.20 255.255.255.0 192.168.0.128 192.168.0.254
After I run
pi@raspberrypi /etc/openvpn $ sudo bash -x ./bridge-start.sh
+ br=br0
+ tap=tap0
+ eth=eth0
+ eth_ip=192.168.0.20
+ eth_netmask=255.255.255.0
+ eth_broadcast=192.168.0.255
+ for t in '$tap'
+ openvpn --mktun --dev tap0
Thu Dec 4 15:26:52 2014 TUN/TAP device tap0 opened
Thu Dec 4 15:26:52 2014 Persist state set to: ON
+ brctl addbr br0
+ brctl addif br0 eth0
+ for t in '$tap'
+ brctl addif br0 tap0
+ for t in '$tap'
+ ifconfig tap0 0.0.0.0 promisc up
+ ifconfig eth0 0.0.0.0 promisc up
+ ifconfig br0 192.168.0.20 netmask 255.255.255.0 broadcast 192.168.0.255
and
pi@raspberrypi /etc/openvpn $ sudo bash -x ./bridge-firewall.sh
+ iptables -A INPUT -i tap0 -j ACCEPT
+ iptables -A INPUT -i br0 -j ACCEPT
+ iptables -A FORWARD -i br0 -j ACCEPT
I restart OpenVPN
pi@raspberrypi /etc/openvpn $ sudo /etc/init.d/openvpn restart
[ ok ] Stopping virtual private network daemon: openvpn.
[ ok ] Starting virtual private network daemon: openvpn.
Then, on the client side i change also
dev tun
to
dev tap
When I then try to connect my Laptop to the VPN bridge (using my mobile connection to access from outside), it doesn't work.
Attempting to establish TCP connection with [AF_INET]62.116.60.58:1194 [nonblock]
MANAGEMENT: >STATE:1417698390,TCP_CONNECT...
TCP: connect to [AF_INET]62.116.60.58:1194 failed, will try again in 5 seconds: The system tried to join a drive to a directory on a joined drive.
This TCP_CONNECT failure repeats all the time then.
The ifconfig showes this:
pi@raspberrypi /etc/openvpn $ ifconfig
br0 Link encap:Ethernet HWaddr b8:27:eb:f4:8b:c4
inet addr:192.168.0.20 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::ba27:ebff:fef4:8bc4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2692 errors:0 dropped:3 overruns:0 frame:0
TX packets:4593 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:289341 (282.5 KiB) TX bytes:4570002 (4.3 MiB)
eth0 Link encap:Ethernet HWaddr b8:27:eb:f4:8b:c4
inet6 addr: fe80::ba27:ebff:fef4:8bc4/64 Scope:Link
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:25900 errors:0 dropped:0 overruns:0 frame:0
TX packets:41977 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4182986 (3.9 MiB) TX bytes:30805401 (29.3 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:76716 errors:0 dropped:0 overruns:0 frame:0
TX packets:76716 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:352217969 (335.9 MiB) TX bytes:352217969 (335.9 MiB)
tap0 Link encap:Ethernet HWaddr d6:2e:98:f2:2f:c0
inet6 addr: fe80::d42e:98ff:fef2:2fc0/64 Scope:Link
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:3 errors:0 dropped:0 overruns:0 frame:0
TX packets:255 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:184 (184.0 B) TX bytes:68505 (66.8 KiB)
I was trying to fix that now for almost 4 days, and I came to the point where I'm sure that I can't solve it on my own. Honestly I'm very bad in network configurations things and don't really understand what I need to do. Neither I know what more except ifconfig you need to find out whats wrong. Sorry for that.
I hope that anyone of you could help me to solve that problem. Thanks a lot!
Mani