Hi openvpn community
I'm setting a vpn server and meet DNS issues.
The server is 2.3.12 running in the latest dd-wrt site main gateway with
--default-gateway def1 and
--topology subnet for 2~3 windows7+ clients.
The client from which I'd like to remotely manage the server is 2.3.2 from my ubuntu 14.04.5.
I didn't need to push site lan route to the client for it to be able to ping IPs in the site lan.
Although I had to manually add a firewall rule so that the client get replies when pinging IPs in the wan:
iptables -t nat -A POSTROUTING -s `nvram get openvpn_net`/`nvram get openvpn_tunmask` -o `get_wanface` -j SNAT --to nvram get wan_ipaddr
The server OS routes are:
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 111.222.333.193 0.0.0.0 UG 0 0 0 vlan2 # ISP gateway IP in the wan
10.0.64.80 0.0.0.0 255.255.255.240 U 0 0 0 tun2 # vpn net
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 br0 # Site lan
111.222.333.192 0.0.0.0 255.255.255.192 U 0 0 0 vlan2 # ISP wan net - my gateway is dhcp allocated 111.222.333.196 plus 2 DNS
The Server isdh /path/dh.pem
ca /path/ca.crt
cert /path/cert.pem
key /path/key.pem
keepalive 10 120
verb 3
mute 3
syslog
writepid /path/openvpnd.pid
management 127.0.0.1 port
management-log-cache size
topology subnet
script-security 2
port 1194
proto udp
cipher same-as-clients
auth same-as-clients
client-connect /path/clcon.sh
client-disconnect /path/cldiscon.sh
client-config-dir /path/ccd
comp-lzo adaptive
tls-server
ifconfig-pool-persist /path/ip-pool 86400
push "redirect-gateway def1"
tls-cipher same-as-clients
fast-io
tun-mtu 1500
mtu-disc yes
server 10.0.64.80 255.255.255.240
dev tun2
tun-ipv6
tls-auth /tmp/openvpn/ta.key 0
push "dhcp-option DNS 192.168.0.254" ## dnsmasq in the gateway
push "route-delay 5 5"
;push "route 192.168.0.0 255.255.255.0"
I see two different behaviour on the client depending on I use:
In network-manager-openvpn where I don't get the 0/1 & 128.0.0.0/1 routes, but I get DNS and can ping & browse both lan & wan names since I allowed the dnsmasq server to listen to the vpn interface in the server
interface=tun2
no-dhcp-interface=tun2
...
[vpn]
service-type=org.freedesktop.NetworkManager.openvpn
ta-dir=1
connection-type=tls
auth=same-as-server
remote=site (ip from my hosts file, same as above)
cipher=same-as-server
comp-lzo=yes
cert-pass-flags=0
port=1194
remote-cert-tls=server
cert=/path/me.crt
ca=/path/site.crt
key=/path/me.key
ta=/path/ta-site.key
[ipv4]
method=auto
or
sudo openvpn site.conf where I get the two routes above but no DNS so that I can't ping names in the site lan nor wan
client
dev tun
proto udp
remote 111.222.333.196 1194
resolv-retry infinite
nobind
;user nobody
;group nogroup
persist-key
persist-tun
mute-replay-warnings
ca site.crt
cert me.crt
key me.key
ns-cert-type server
tls-auth ta-site.key 1
auth same-as-server
cipher same-as-server
tls-cipher same-as-server
comp-lzo
verb 4
mute 20
nslookup device_in_server_lan or wan
;; connection timed out; no servers could be reached
me@client:~/openvpn$ nslookup device_in_server_lan 192.168.0.254
Server: 192.168.0.254
Address: 192.168.0.254#53
Name: device_in_server_lan
Address: 192.168.0.249
#same for name on wan, with additional notif "Non-authoritative answer:"
Please what should I do to have this command line to work ? I read the man and see push dhcp options is not compatible with linux but n-m-o works. Although maybe this a up script case of use but I found no example on this in the man
Here is the client log:
...
Sun Nov 27 22:11:08 2016 us=774252 [Server] Peer Connection Initiated with [AF_INET]111.222.333.196:1194
Sun Nov 27 22:11:11 2016 us=148707 SENT CONTROL [Srveur]: 'PUSH_REQUEST' (status=1)
Sun Nov 27 22:11:11 2016 us=213621 PUSH: Received control message: 'PUSH_REPLY,redirect-gateway def1,dhcp-option DNS 192.168.0.254,route-delay 5 5,route-gateway 10.0.64.81,topology subnet,ping 10,ping-restart 120,ifconfig 10.0.64.82 255.255.255.240'
Sun Nov 27 22:11:11 2016 us=213697 OPTIONS IMPORT: timers and/or timeouts modified
Sun Nov 27 22:11:11 2016 us=213705 OPTIONS IMPORT: --ifconfig/up options modified
Sun Nov 27 22:11:11 2016 us=213709 OPTIONS IMPORT: route options modified
Sun Nov 27 22:11:11 2016 us=213713 OPTIONS IMPORT: route-related options modified
Sun Nov 27 22:11:11 2016 us=213717 OPTIONS IMPORT: --ip-win32 and/or --dhcp-option options modified
Sun Nov 27 22:11:11 2016 us=213851 ROUTE_GATEWAY home.lan.gw.ipaddr/255.255.255.0 IFACE=wlan0 HWADDR=la:pm:ac:ad:dr:es
Sun Nov 27 22:11:11 2016 us=214028 TUN/TAP device tun0 opened
Sun Nov 27 22:11:11 2016 us=214057 TUN/TAP TX queue length set to 100
Sun Nov 27 22:11:11 2016 us=214075 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
Sun Nov 27 22:11:11 2016 us=214100 /sbin/ip link set dev tun0 up mtu 1500
Sun Nov 27 22:11:11 2016 us=216235 /sbin/ip addr add dev tun0 10.0.64.82/28 broadcast 10.0.64.95
Sun Nov 27 22:11:16 2016 us=408754 /sbin/ip route add 111.222.333.196/32 via home.lan.gw.ipaddr
Sun Nov 27 22:11:16 2016 us=409992 /sbin/ip route add 0.0.0.0/1 via 10.0.64.81
Sun Nov 27 22:11:16 2016 us=411269 /sbin/ip route add 128.0.0.0/1 via 10.0.64.81
Sun Nov 27 22:11:16 2016 us=413109 Initialization Sequence Completed
Thank you for advises