OK, so, I decided to try the guide at this URL (
http://backreference.org/2009/11/15/openvpn-and-iroute/), which basically uses ccd files.
I have a user for each VPC. But, for debug purposes, I'm only focusing on dev.
USER: dev-hqs
Network: 10.100.0.0/16
VPN GW: 10.0.0.2/24
The vpn "server" is acting as a client in the 10.100.0.0/16 network and connects to my main office SERVER (which is acting purely in a server capacity now). This server sits in 192.168.1.0/24. And, I can browse from this server to anything 10.100.0.0/16. OK, good.
But, now my:
1) My roadwarriors are connecting to the office SERVER too (in 192.168.1.0/24). They are getting an IP of 10.0.0.2 (!!??)
2) They can ping 10.0.0.1 and ping 10.0.0.2. But, I can't connect to 10.100.0.0/16. 🙁 Here's the routes for the test user on windows:
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.220 10
10.0.0.0 255.255.255.0 On-link 10.0.0.2 286
10.0.0.0 255.255.255.0 10.0.0.1 10.0.0.2 30
10.0.0.2 255.255.255.255 On-link 10.0.0.2 286
10.0.0.255 255.255.255.255 On-link 10.0.0.2 286
10.100.0.0 255.255.0.0 10.0.0.1 10.0.0.2 30
127.0.0.0 255.0.0.0 On-link 127.0.0.1 306
127.0.0.1 255.255.255.255 On-link 127.0.0.1 306
127.255.255.255 255.255.255.255 On-link 127.0.0.1 306
192.168.1.0 255.255.255.0 On-link 192.168.1.220 266
192.168.1.220 255.255.255.255 On-link 192.168.1.220 266
192.168.1.255 255.255.255.255 On-link 192.168.1.220 266
224.0.0.0 240.0.0.0 On-link 127.0.0.1 306
224.0.0.0 240.0.0.0 On-link 192.168.1.220 266
224.0.0.0 240.0.0.0 On-link 10.0.0.2 286
255.255.255.255 255.255.255.255 On-link 127.0.0.1 306
255.255.255.255 255.255.255.255 On-link 192.168.1.220 266
255.255.255.255 255.255.255.255 On-link 10.0.0.2 286
===========================================================================
Persistent Routes:
None
3) How do I configure those users to pull a dynamic ip? I'd like to just use the same CCD file for all road warriors if possible.
Here's the CCD file I'm pushing to the VPCs (10.100.0.0/24) client/proxy:
ifconfig-push 10.0.0.2 255.255.255.0
push "route 192.168.1.0 255.255.255.0 10.0.0.1"
iroute 10.100.0.0 255.255.0.0
Here's the CCD template file I'm fiddling with for my roadwarrors (all of whom use windows to connect):
ifconfig-push 10.0.0.5 255.255.255.0
push "route 192.168.1.0 255.255.255.0 10.0.0.1"
push "route 10.100.0.0 255.255.0.0 10.0.0.2"
Here's my server config:
## HQS - Server
# local 172.20.0.1 ##May not need this?
port 1196
proto udp
dev tun
topology subnet
mode server
tls-server
tun-mtu 1500
tun-mtu-extra 32
mssfix 1450
client-to-client
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/hqs-openvpn.myco.co.crt
key /etc/openvpn/easy-rsa/keys/hqs-openvpn.myco.co.key
dh /etc/openvpn/easy-rsa/keys/dh1024.pem
plugin /usr/lib/openvpn/openvpn-auth-pam.so /etc/pam.d/login #- Comment this line if you are using FreeRADIUS
#plugin /etc/openvpn/radiusplugin.so /etc/openvpn/radiusplugin.cnf #- Uncomment this line if you are using FreeRADIUS
client-cert-not-required
username-as-common-name
server 10.0.0.0 255.255.255.0
ifconfig 10.0.0.1 255.255.255.0
#route 192.168.1.1 255.255.0.0 10.0.0.1 #HQS
route 10.100.0.0 255.255.0.0 10.0.0.2 #DEV
route 10.101.0.0 255.255.0.0 10.0.0.3 #QA
route 10.104.0.0 255.255.0.0 10.0.0.4 #PROD
client-config-dir ccd
#push "redirect-gateway def1"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
push "route 10.0.0.0 255.255.255.0"
push "route 10.100.0.0 255.255.0.0"
keepalive 5 30
comp-lzo
persist-key
persist-tun
verb 3
user nobody
group nogroup
log-append /var/log/openvpn
status /tmp/vpn.status 10
Here's my client config (linux-based VPNs in the VPCs):
client
dev tun
proto udp
remote vpn.mycompany.co 1196
resolv-retry infinite
nobind
persist-key
persist-tun
ca /etc/openvpn/ca.crt
auth-user-pass /tmp/password.txt
comp-lzo
verb 3
reneg-sec 0
tls-client
remote-cert-tls server
Here's my client config (roadwarriors / windows):
client
dev tun
proto udp
remote vpn.mycomapny.co 1196 # - Your server IP and OpenVPN Port
resolv-retry infinite
nobind
#tun-mtu 1500
#tun-mtu-extra 32
#mssfix 1450
persist-key
persist-tun
ca ca.crt
auth-user-pass
comp-lzo
verb 3
reneg-sec 0
tls-client
remote-cert-tls server
#topolgy subnet
On my server, here's the output of (iptables -vnL; iptables -t nat -vnL; iptables -t mangle -vnL; route -n):
root@ip-10-100-0-15:~# iptables -vnL; iptables -t nat -vnL; iptables -t mangle -vnL; route -n
Chain INPUT (policy ACCEPT 22 packets, 1570 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- * * 10.0.0.0/24 0.0.0.0/0
0 0 ACCEPT all -- tun+ * 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:1196
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- * * 192.168.1.0 0.0.0.0/0
0 0 ACCEPT all -- * * 10.0.0.0/24 0.0.0.0/0
0 0 ACCEPT all -- tun+ * 0.0.0.0/0 0.0.0.0/0
Chain OUTPUT (policy ACCEPT 15 packets, 1990 bytes)
pkts bytes target prot opt in out source destination
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 1 packets, 62 bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 1 packets, 62 bytes)
pkts bytes target prot opt in out source destination
0 0 MASQUERADE all -- * eth0 10.0.0.0/24 0.0.0.0/0
Chain PREROUTING (policy ACCEPT 22 packets, 1570 bytes)
pkts bytes target prot opt in out source destination
Chain INPUT (policy ACCEPT 22 packets, 1570 bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 24 packets, 3482 bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 24 packets, 3482 bytes)
pkts bytes target prot opt in out source destination
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.100.0.1 0.0.0.0 UG 100 0 0 eth0
10.0.0.0 10.0.0.1 255.255.255.0 UG 0 0 0 tun0
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 tun0
10.100.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.1.0 10.0.0.1 255.255.255.0 UG 0 0 0 tun0
On my VPC (10.100.0.0/16 network), here's the output of (iptables -vnL; iptables -t nat -vnL; iptables -t mangle -vnL; route -n):
root@vpn-hqs:/etc/openvpn/ccd# iptables -vnL; iptables -t nat -vnL; iptables -t mangle -vnL; route -n
Chain INPUT (policy ACCEPT 190 packets, 347K bytes)
pkts bytes target prot opt in out source destination
2926 385K ACCEPT all -- * * 192.168.1.0/24 0.0.0.0/0
0 0 ACCEPT all -- * * 10.0.0.0/24 0.0.0.0/0
12 648 ACCEPT all -- tun+ * 0.0.0.0/0 0.0.0.0/0
525 40675 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:1196
2 120 ACCEPT all -- * * 10.0.0.0/24 0.0.0.0/0
24 1296 ACCEPT all -- tun+ * 0.0.0.0/0 0.0.0.0/0
1245 96055 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:1196
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- * * 192.168.1.0/24 0.0.0.0/0
0 0 ACCEPT all -- * * 10.0.0.0/24 0.0.0.0/0
0 0 ACCEPT all -- tun+ * 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT all -- * * 10.0.0.0/24 0.0.0.0/0
0 0 ACCEPT all -- * * 192.168.1.0/24 0.0.0.0/0
0 0 ACCEPT all -- * * 192.168.1.0/24 0.0.0.0/0
5 355 ACCEPT all -- * * 10.0.0.0/24 0.0.0.0/0
0 0 ACCEPT all -- tun+ * 0.0.0.0/0 0.0.0.0/0
Chain OUTPUT (policy ACCEPT 627 packets, 64553 bytes)
pkts bytes target prot opt in out source destination
Chain PREROUTING (policy ACCEPT 927 packets, 137K bytes)
pkts bytes target prot opt in out source destination
Chain INPUT (policy ACCEPT 842 packets, 134K bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 25 packets, 1548 bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 25 packets, 1548 bytes)
pkts bytes target prot opt in out source destination
Chain PREROUTING (policy ACCEPT 2669 packets, 677K bytes)
pkts bytes target prot opt in out source destination
Chain INPUT (policy ACCEPT 2584 packets, 673K bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 711 packets, 75641 bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 711 packets, 75641 bytes)
pkts bytes target prot opt in out source destination
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 100 0 0 eth0
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 tun0
10.100.0.0 10.0.0.2 255.255.0.0 UG 0 0 0 tun0
10.101.0.0 10.0.0.3 255.255.0.0 UG 0 0 0 tun0
10.104.0.0 10.0.0.4 255.255.0.0 UG 0 0 0 tun0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0