I tried to search for a solution, which might be obvious, but I am not able to get my OpenVPN connection working the way I would like.
My setup is:
router which acts as DHCP in the range 192.168.1.0 255.255.255
Raspberry Pi (debian) with a fixed ipadres 192.168.1.98
I would like to connect my Ipad, Android phone and a windows 7 laptop to my network and surf abroad like I am at home, so my local IP is transferred.
At this stage I am able to connect all my devices from different networks to my VPN without a problem (explore on ip adres). But surfing external is not possible.
my server.conf
ev tun
proto udp
port 1194
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
persist-key
persist-tun
status /var/log/openvpn-status.log
verb 3
client-to-client
push "redirect-gateway def1"
#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
my ovpn
dev tun
client
proto udp
remote <ex.ip.adres> 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert client1.crt
key client1.key
comp-lzo
verb 3
output of ifconfig
eth0 Link encap:Ethernet HWaddr b8:27:eb:54:ca:99
inet addr:192.168.1.98 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:633038 errors:0 dropped:0 overruns:0 frame:0
TX packets:246113 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:160146143 (152.7 MiB) TX bytes:61977612 (59.1 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:394 errors:0 dropped:0 overruns:0 frame:0
TX packets:394 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:30496 (29.7 KiB) TX bytes:30496 (29.7 KiB)
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:4123 errors:0 dropped:0 overruns:0 frame:0
TX packets:2215 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:335455 (327.5 KiB) TX bytes:377143 (368.3 KiB)
rc.local
iptables -t nat -A INPUT -i eth0 -p udp -m udp --dport 1194 -j ACCEPT
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j SNAT --to-source 192.168.1.98
statuslog
OpenVPN CLIENT LIST
Updated,Wed Feb 5 12:35:43 2014
Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since
client1,<public ip networkadres>:35539,12588,11774,Wed Feb 5 12:35:25 2014
ROUTING TABLE
Virtual Address,Common Name,Real Address,Last Ref
10.8.0.6,<public ip networkadres>:35539,Wed Feb 5 12:35:42 2014
GLOBAL STATS
Max bcast/mcast queue length,0
END
logfile (startup openvpn, connect client and disconnect client)
Wed Feb 5 12:38:09 2014 OpenVPN 2.2.1 arm-linux-gnueabihf [SSL] [LZO2] [EPOLL] [PKCS11] [eurephia] [MH] [PF_INET6] [IPv6 payload 20110424-2 (2.2RC2)] built on Oct 12 2013
Wed Feb 5 12:38:09 2014 WARNING: --keepalive option is missing from server config
Wed Feb 5 12:38:09 2014 NOTE: your local LAN uses the extremely common subnet address 192.168.0.x or 192.168.1.x. Be aware that this might create routing conflicts if you connect to the VPN server from public locations such as internet cafes that use the same subnet.
Wed Feb 5 12:38:09 2014 NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables
Wed Feb 5 12:38:09 2014 Diffie-Hellman initialized with 1024 bit key
Wed Feb 5 12:38:09 2014 TLS-Auth MTU parms [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 ]
Wed Feb 5 12:38:09 2014 Socket Buffers: R=[163840->131072] S=[163840->131072]
Wed Feb 5 12:38:09 2014 ROUTE default_gateway=192.168.1.1
Wed Feb 5 12:38:09 2014 TUN/TAP device tun0 opened
Wed Feb 5 12:38:09 2014 TUN/TAP TX queue length set to 100
Wed Feb 5 12:38:09 2014 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
Wed Feb 5 12:38:09 2014 /sbin/ifconfig tun0 10.8.0.1 pointopoint 10.8.0.2 mtu 1500
Wed Feb 5 12:38:09 2014 /sbin/route add -net 10.8.0.0 netmask 255.255.255.0 gw 10.8.0.2
Wed Feb 5 12:38:09 2014 Data Channel MTU parms [ L:1542 D:1450 EF:42 EB:135 ET:0 EL:0 AF:3/1 ]
Wed Feb 5 12:38:09 2014 GID set to nogroup
Wed Feb 5 12:38:09 2014 UID set to nobody
Wed Feb 5 12:38:09 2014 UDPv4 link local (bound): [undef]
Wed Feb 5 12:38:09 2014 UDPv4 link remote: [undef]
Wed Feb 5 12:38:09 2014 MULTI: multi_init called, r=256 v=256
Wed Feb 5 12:38:09 2014 IFCONFIG POOL: base=10.8.0.4 size=62, ipv6=0
Wed Feb 5 12:38:09 2014 Initialization Sequence Completed
Wed Feb 5 12:38:12 2014 MULTI: multi_create_instance called
Wed Feb 5 12:38:12 2014 <remote IP adres public network>:36136 Re-using SSL/TLS context
Wed Feb 5 12:38:12 2014 <remote IP adres public network>:36136 LZO compression initialized
Wed Feb 5 12:38:12 2014 <remote IP adres public network>:36136 Control Channel MTU parms [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 ]
Wed Feb 5 12:38:12 2014 <remote IP adres public network>:36136 Data Channel MTU parms [ L:1542 D:1450 EF:42 EB:135 ET:0 EL:0 AF:3/1 ]
Wed Feb 5 12:38:12 2014 <remote IP adres public network>:36136 Local Options hash (VER=V4): '530fdded'
Wed Feb 5 12:38:12 2014 <remote IP adres public network>:36136 Expected Remote Options hash (VER=V4): '41690919'
Wed Feb 5 12:38:12 2014 <remote IP adres public network>:36136 TLS: Initial packet from [AF_INET]<remote IP adres public network>:36136, sid=e8d4ba09 0630d6ce
Wed Feb 5 12:38:12 2014 <remote IP adres public network>:36136 VERIFY OK: depth=1, /C=US/ST=CA/L=SanFrancisco/O=Fort-Funston/OU=changeme/CN=changeme/name=changeme/emailAddress=mail@host.domain
Wed Feb 5 12:38:12 2014 <remote IP adres public network>:36136 VERIFY OK: depth=0, /C=US/ST=CA/L=SanFrancisco/O=Fort-Funston/OU=changeme/CN=client1/name=changeme/emailAddress=mail@host.domain
Wed Feb 5 12:38:12 2014 <remote IP adres public network>:36136 Data Channel Encrypt: Cipher 'BF-CBC' initialized with 128 bit key
Wed Feb 5 12:38:12 2014 <remote IP adres public network>:36136 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Wed Feb 5 12:38:12 2014 <remote IP adres public network>:36136 Data Channel Decrypt: Cipher 'BF-CBC' initialized with 128 bit key
Wed Feb 5 12:38:12 2014 <remote IP adres public network>:36136 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Wed Feb 5 12:38:12 2014 <remote IP adres public network>:36136 Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA, 1024 bit RSA
Wed Feb 5 12:38:12 2014 <remote IP adres public network>:36136 [client1] Peer Connection Initiated with [AF_INET]<remote IP adres public network>:36136
Wed Feb 5 12:38:12 2014 client1/<remote IP adres public network>:36136 MULTI_sva: pool returned IPv4=10.8.0.6, IPv6=bccd:800:8ced:200:14c2:700:bc64:c001
Wed Feb 5 12:38:12 2014 client1/<remote IP adres public network>:36136 MULTI: Learn: 10.8.0.6 -> client1/<remote IP adres public network>:36136
Wed Feb 5 12:38:12 2014 client1/<public ip adres network>:36136 MULTI: primary virtual IP for client1/<remote IP adres public network>:36136: 10.8.0.6
Wed Feb 5 12:38:13 2014 client1/<public ip adres network>:36136 PUSH: Received control message: 'PUSH_REQUEST'
Wed Feb 5 12:38:13 2014 client1/<public ip adres network>:36136 send_push_reply(): safe_cap=960
Wed Feb 5 12:38:13 2014 client1/<public ip adres network>:36136 SENT CONTROL [client1]: 'PUSH_REPLY,redirect-gateway def1,dhcp-option DNS 8.8.8.8,dhcp-option DNS 8.8.4.4,route 10.8.0.0 255.255.255.0,topology net30,ifconfig 10.8.0.6 10.8.0.5' (status=1)
Wed Feb 5 12:38:57 2014 client1/<public ip adres network>:36136 SIGTERM[soft,remote-exit] received, client-instance exiting
Hopefully, somebody can give me hint in the correct direction. I played around with several option for the iptables, but without success. The different masks in the output of ifconfig might be the issue, but I have no clue which I need to change to make it work.