I installed openvpn on a centos7 server:
port 1194
proto udp
dev tun
ca ca.crt
cert server.crt
key server.key # This file should be kept secret
dh dh2048.pem
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 10.10.10.76"
push "dhcp-option DNS 10.10.10.107"
keepalive 10 120
comp-lzo
user nobody
group nobody
persist-key
persist-tun
status openvpn-status.log
log openvpn.log
log-append openvpn.log
verb 5
I uncommented:
push "dhcp-option DNS 10.10.10.76"
push "dhcp-option DNS 10.10.10.107"
and changed the default values with our subnet's dns servers.
I also updated iptables to the following:
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
On my client (mac), the client.ovpn is as follows:
client
dev tun
proto udp
remote gatekeeper 1194
resolv-retry infinite
nobind
persist-key
persist-tun
comp-lzo
verb 3
ca client-keys/ca.crt
cert client-keys/client.crt
key client-keys/client.key
I can connect to the vpn, and here is the output (I changed my external ips to 555.555.555)
sudo openvpn --config client.ovpn
Tue Sep 29 16:22:30 2015 OpenVPN 2.3.6 x86_64-apple-darwin13.4.0 [SSL (OpenSSL)] [LZO] [MH] [IPv6] built on Dec 2 2014
Tue Sep 29 16:22:30 2015 library versions: OpenSSL 1.0.2a 19 Mar 2015, LZO 2.08
Tue Sep 29 16:22:30 2015 WARNING: No server certificate verification method has been enabled. See http://openvpn.net/howto.html#mitm for more info.
Tue Sep 29 16:22:30 2015 Socket Buffers: R=[196724->65536] S=[9216->65536]
Tue Sep 29 16:22:30 2015 UDPv4 link local: [undef]
Tue Sep 29 16:22:30 2015 UDPv4 link remote: [AF_INET]555.555.555.72:1194
Tue Sep 29 16:22:30 2015 TLS: Initial packet from [AF_INET]555.555.555.72:1194, sid=bf1881ff 3dcdc7c7
Tue Sep 29 16:22:30 2015 VERIFY OK: depth=1, C=US, ST=VA, L=Falls Church, O=example, OU=Dev, CN=gateway.colo.example.com, name=gateway, emailAddress=mmerrell@example.com
Tue Sep 29 16:22:30 2015 VERIFY OK: depth=0, C=US, ST=VA, L=Falls Church, O=example, OU=Dev, CN=gateway.colo.example.com, name=gateway, emailAddress=mmerrell@example.com
Tue Sep 29 16:22:30 2015 Data Channel Encrypt: Cipher 'BF-CBC' initialized with 128 bit key
Tue Sep 29 16:22:30 2015 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Tue Sep 29 16:22:30 2015 Data Channel Decrypt: Cipher 'BF-CBC' initialized with 128 bit key
Tue Sep 29 16:22:30 2015 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Tue Sep 29 16:22:30 2015 Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA, 2048 bit RSA
Tue Sep 29 16:22:30 2015 [gateway.colo.example.com] Peer Connection Initiated with [AF_INET]555.555.555.72:1194
Tue Sep 29 16:22:33 2015 SENT CONTROL [gateway.colo.example.com]: 'PUSH_REQUEST' (status=1)
Tue Sep 29 16:22:33 2015 PUSH: Received control message: 'PUSH_REPLY,redirect-gateway def1 bypass-dhcp,dhcp-option DNS 10.10.10.76,dhcp-option DNS 10.10.10.107,route 10.8.0.1,topology net30,ping 10,ping-restart 120,ifconfig 10.8.0.6 10.8.0.5'
Tue Sep 29 16:22:33 2015 OPTIONS IMPORT: timers and/or timeouts modified
Tue Sep 29 16:22:33 2015 OPTIONS IMPORT: --ifconfig/up options modified
Tue Sep 29 16:22:33 2015 OPTIONS IMPORT: route options modified
Tue Sep 29 16:22:33 2015 OPTIONS IMPORT: --ip-win32 and/or --dhcp-option options modified
Tue Sep 29 16:22:33 2015 Opened utun device utun0
Tue Sep 29 16:22:33 2015 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
Tue Sep 29 16:22:33 2015 /sbin/ifconfig utun0 delete
ifconfig: ioctl (SIOCDIFADDR): Can't assign requested address
Tue Sep 29 16:22:33 2015 NOTE: Tried to delete pre-existing tun/tap instance -- No Problem if failure
Tue Sep 29 16:22:33 2015 /sbin/ifconfig utun0 10.8.0.6 10.8.0.5 mtu 1500 netmask 255.255.255.255 up
Tue Sep 29 16:22:33 2015 /sbin/route add -net 555.555.555.72 10.10.50.1 255.255.255.255
add net 555.555.555.72: gateway 10.10.50.1
Tue Sep 29 16:22:33 2015 /sbin/route add -net 0.0.0.0 10.8.0.5 128.0.0.0
add net 0.0.0.0: gateway 10.8.0.5
Tue Sep 29 16:22:33 2015 /sbin/route add -net 128.0.0.0 10.8.0.5 128.0.0.0
add net 128.0.0.0: gateway 10.8.0.5
Tue Sep 29 16:22:33 2015 /sbin/route add -net 10.8.0.1 10.8.0.5 255.255.255.255
add net 10.8.0.1: gateway 10.8.0.5
Tue Sep 29 16:22:33 2015 Initialization Sequence Completed
After I connect I can ping the openvpn server:
ping 10.8.0.1 and my client/self
ping 10.8.0.6
I cannot ping external servers, internal servers on the openvpn subnet, or resolve ips.
ping 10.10.10.25 (server on openvpn subnet)
ping yahoo.com (won't resolve)
ping 98.138.253.109 (yahoos ip)
Any help trouble shooting this would be really helpful. I'd like to be able connect and access the servers on the subnet, and I'd like to be able to also have external internet access.
thanks.
myles.