Set up openvpn in routed mode (mode tun) and set up routing in that VM; then set up the second VM and give it the first VM as the default gateway. After that, it is all a matter of routing
I have tried, but can't make it work. I am stuck and would really appreciate some help on this.
I have two VirtualBox VM's with network set to bridged adapter.
First VM (IP 10.0.0.8):
I started OpenVPN in this VM and logged in on vpnbook free using the following ovpn file (just for testing, I will eventually use other provider):
Code: Select all
client
dev tun0
proto udp
remote 93.115.84.194 53
remote euro1.vpnbook.com 53
resolv-retry infinite
nobind
persist-key
persist-tun
ca vpnbook-ca.crt
auth-user-pass
comp-lzo
verb 3
cipher AES-128-CBC
fast-io
pull
route-delay 2
redirect-gateway
The OpenVPN sign-on produced this output (DNS Server IP's have been hidden):
Code: Select all
Wed May 22 16:29:59 2013 OpenVPN 2.3.1 i686-w64-mingw32 [SSL (OpenSSL)] [LZO] [PKCS11] [eurephia] [IPv6] built on Mar 28 2013
Wed May 22 16:29:59 2013 WARNING: No server certificate verification method has been enabled. See http://openvpn.net/howto.html#mitm for more info.
Wed May 22 16:29:59 2013 NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables
Wed May 22 16:29:59 2013 NOTE: --fast-io is disabled since we are running on Windows
Wed May 22 16:29:59 2013 Socket Buffers: R=[8192->8192] S=[8192->8192]
Wed May 22 16:29:59 2013 UDPv4 link local: [undef]
Wed May 22 16:29:59 2013 UDPv4 link remote: [AF_INET]93.115.84.194:53
Wed May 22 16:29:59 2013 TLS: Initial packet from [AF_INET]93.115.84.194:53, sid=6e77f58d 5e571031
Wed May 22 16:29:59 2013 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this
Wed May 22 16:30:00 2013 VERIFY OK: depth=1, C=CH, ST=Zurich, L=Zurich, O=vpnbook.com, OU=IT, CN=vpnbook.com, name=vpnbook.com, emailAddress=admin@vpnbook.com
Wed May 22 16:30:00 2013 VERIFY OK: depth=0, C=CH, ST=Zurich, L=Zurich, O=vpnbook.com, OU=IT, CN=vpnbook.com, name=vpnbook.com, emailAddress=admin@vpnbook.com
Wed May 22 16:30:00 2013 Data Channel Encrypt: Cipher 'AES-128-CBC' initialized with 128 bit key
Wed May 22 16:30:00 2013 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Wed May 22 16:30:00 2013 Data Channel Decrypt: Cipher 'AES-128-CBC' initialized with 128 bit key
Wed May 22 16:30:00 2013 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Wed May 22 16:30:00 2013 Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA, 1024 bit RSA
Wed May 22 16:30:00 2013 [vpnbook.com] Peer Connection Initiated with [AF_INET]93.115.84.194:53
Wed May 22 16:30:03 2013 SENT CONTROL [vpnbook.com]: 'PUSH_REQUEST' (status=1)
Wed May 22 16:30:03 2013 PUSH: Received control message: 'PUSH_REPLY,redirect-gateway def1,dhcp-option DNS 1.2.3.4,dhcp-option DNS 1.2.3.5,route 10.8.0.1,topology net30,ping 5,ping-restart 30,ifconfig 10.8.0.130 10.8.0.129'
Wed May 22 16:30:03 2013 OPTIONS IMPORT: timers and/or timeouts modified
Wed May 22 16:30:03 2013 OPTIONS IMPORT: --ifconfig/up options modified
Wed May 22 16:30:03 2013 OPTIONS IMPORT: route options modified
Wed May 22 16:30:03 2013 OPTIONS IMPORT: --ip-win32 and/or --dhcp-option options modified
Wed May 22 16:30:03 2013 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
Wed May 22 16:30:03 2013 open_tun, tt->ipv6=0
Wed May 22 16:30:03 2013 TAP-WIN32 device [Local Area Connection 2] opened: \\.\Global\{A171C600-6DAB-4CF7-83E3-EBF6CEF6A36D}.tap
Wed May 22 16:30:03 2013 TAP-Windows Driver Version 9.9
Wed May 22 16:30:03 2013 Notified TAP-Windows driver to set a DHCP IP/netmask of 10.8.0.130/255.255.255.252 on interface {A171C600-6DAB-4CF7-83E3-EBF6CEF6A36D} [DHCP-serv: 10.8.0.129, lease-time: 31536000]
Wed May 22 16:30:03 2013 Successful ARP Flush on interface [3] {A171C600-6DAB-4CF7-83E3-EBF6CEF6A36D}
Wed May 22 16:30:05 2013 TEST ROUTES: 0/0 succeeded len=1 ret=0 a=0 u/d=down
Wed May 22 16:30:05 2013 Route: Waiting for TUN/TAP interface to come up...
Wed May 22 16:30:07 2013 TEST ROUTES: 0/0 succeeded len=1 ret=0 a=0 u/d=down
Wed May 22 16:30:07 2013 Route: Waiting for TUN/TAP interface to come up...
Wed May 22 16:30:08 2013 TEST ROUTES: 0/0 succeeded len=1 ret=0 a=0 u/d=down
Wed May 22 16:30:08 2013 Route: Waiting for TUN/TAP interface to come up...
Wed May 22 16:30:09 2013 TEST ROUTES: 2/2 succeeded len=1 ret=1 a=0 u/d=up
Wed May 22 16:30:09 2013 C:\WINDOWS\system32\route.exe ADD 93.115.84.194 MASK 255.255.255.255 10.0.0.1
Wed May 22 16:30:09 2013 Route addition via IPAPI succeeded [adaptive]
Wed May 22 16:30:09 2013 C:\WINDOWS\system32\route.exe ADD 0.0.0.0 MASK 128.0.0.0 10.8.0.129
Wed May 22 16:30:09 2013 Route addition via IPAPI succeeded [adaptive]
Wed May 22 16:30:09 2013 C:\WINDOWS\system32\route.exe ADD 128.0.0.0 MASK 128.0.0.0 10.8.0.129
Wed May 22 16:30:09 2013 Route addition via IPAPI succeeded [adaptive]
Wed May 22 16:30:09 2013 C:\WINDOWS\system32\route.exe ADD 10.8.0.1 MASK 255.255.255.255 10.8.0.129
Wed May 22 16:30:09 2013 Route addition via IPAPI succeeded [adaptive]
Wed May 22 16:30:09 2013 Initialization Sequence Completed
Wed May 22 17:30:00 2013 TLS: soft reset sec=0 bytes=110395/0 pkts=1556/0
Wed May 22 17:30:01 2013 VERIFY OK: depth=1, C=CH, ST=Zurich, L=Zurich, O=vpnbook.com, OU=IT, CN=vpnbook.com, name=vpnbook.com, emailAddress=admin@vpnbook.com
Wed May 22 17:30:01 2013 VERIFY OK: depth=0, C=CH, ST=Zurich, L=Zurich, O=vpnbook.com, OU=IT, CN=vpnbook.com, name=vpnbook.com, emailAddress=admin@vpnbook.com
Wed May 22 17:30:01 2013 Data Channel Encrypt: Cipher 'AES-128-CBC' initialized with 128 bit key
Wed May 22 17:30:01 2013 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Wed May 22 17:30:01 2013 Data Channel Decrypt: Cipher 'AES-128-CBC' initialized with 128 bit key
Wed May 22 17:30:01 2013 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Wed May 22 17:30:01 2013 Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA, 1024 bit RSA
That gave me a new interface 10.8.0.130 and public IP 93.115.84.194
ipconfig and routs on first VM are now these:
Code: Select all
C:\>ipconfig /all
Windows IP Configuration
Host Name . . . . . . . . . . . . : XP-SP3-net-nr2a
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Unknown
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : AMD PCNET Family PCI Ethernet Adapter
Physical Address. . . . . . . . . : 08-00-27-1F-E1-E9
Dhcp Enabled. . . . . . . . . . . : No
IP Address. . . . . . . . . . . . : 10.0.0.8
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 10.0.0.1
DNS Servers . . . . . . . . . . . : 10.0.0.1
Ethernet adapter Local Area Connection 2:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : TAP-Windows Adapter V9
Physical Address. . . . . . . . . : 00-FF-A1-71-C6-00
Dhcp Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IP Address. . . . . . . . . . . . : 10.8.0.130
Subnet Mask . . . . . . . . . . . : 255.255.255.252
Default Gateway . . . . . . . . . : 10.8.0.129
DHCP Server . . . . . . . . . . . : 10.8.0.129
DNS Servers . . . . . . . . . . . : 1.2.3.4
1.2.3.5
Lease Obtained. . . . . . . . . . : 22 may 2013 16:30:08
Lease Expires . . . . . . . . . . : 22 may 2014 16:30:08
C:\>route print
===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x2 ...08 00 27 1f e1 e9 ...... AMD PCNET Family PCI Ethernet Adapter - Packet Scheduler Miniport
0x3 ...00 ff a1 71 c6 00 ...... TAP-Windows Adapter V9 - Packet Scheduler Miniport
===========================================================================
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 10.0.0.1 10.0.0.8 1
0.0.0.0 128.0.0.0 10.8.0.129 10.8.0.130 1
10.0.0.0 255.255.255.0 10.0.0.8 10.0.0.8 20
10.0.0.8 255.255.255.255 127.0.0.1 127.0.0.1 20
10.8.0.1 255.255.255.255 10.8.0.129 10.8.0.130 1
10.8.0.128 255.255.255.252 10.8.0.130 10.8.0.130 30
10.8.0.130 255.255.255.255 127.0.0.1 127.0.0.1 30
10.255.255.255 255.255.255.255 10.0.0.8 10.0.0.8 20
10.255.255.255 255.255.255.255 10.8.0.130 10.8.0.130 30
93.115.84.194 255.255.255.255 10.0.0.1 10.0.0.8 1
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
128.0.0.0 128.0.0.0 10.8.0.129 10.8.0.130 1
224.0.0.0 240.0.0.0 10.0.0.8 10.0.0.8 20
224.0.0.0 240.0.0.0 10.8.0.130 10.8.0.130 30
255.255.255.255 255.255.255.255 10.0.0.8 10.0.0.8 1
255.255.255.255 255.255.255.255 10.8.0.130 10.8.0.130 1
Default Gateway: 10.8.0.129
===========================================================================
Persistent Routes:
None
Second VM (IP 10.0.0.5):
This second VM should be able to use the internet connection provided by OpenVPN in the first VM above.
To set the first VM as default gateway for this second VM, I entered this command:
Code: Select all
route add 0.0.0.0 mask 128.0.0.0 10.0.0.8
In this second VM, I can now ping 10.0.0.8 and 10.8.0.130.
But I can NOT ping 10.8.0.129 or 93.115.84.194 or 8.8.8.8 (no internet connection).
ipconfig and routs on second VM are these:
Code: Select all
C:\>ipconfig /all
Windows IP Configuration
Host Name . . . . . . . . . . . . : XP-SP3-net-nr2b
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Unknown
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : AMD PCNET Family PCI Ethernet Adapter
Physical Address. . . . . . . . . : 08-00-27-1C-33-7B
Dhcp Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IP Address. . . . . . . . . . . . : 10.0.0.5
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 10.0.0.1
10.0.0.8
DHCP Server . . . . . . . . . . . : 10.0.0.1
DNS Servers . . . . . . . . . . . : 10.0.0.1
Lease Obtained. . . . . . . . . . : 22 may 2013 16:20:27
Lease Expires . . . . . . . . . . : 23 may 2013 16:20:27
C:\>route print
===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x2 ...08 00 27 1c 33 7b ...... AMD PCNET Family PCI Ethernet Adapter - Packet Scheduler Miniport
===========================================================================
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 10.0.0.1 10.0.0.5 20
0.0.0.0 128.0.0.0 10.0.0.8 10.0.0.5 1
10.0.0.0 255.255.255.0 10.0.0.5 10.0.0.5 20
10.0.0.5 255.255.255.255 127.0.0.1 127.0.0.1 20
10.255.255.255 255.255.255.255 10.0.0.5 10.0.0.5 20
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
224.0.0.0 240.0.0.0 10.0.0.5 10.0.0.5 20
255.255.255.255 255.255.255.255 10.0.0.5 10.0.0.5 1
Default Gateway: 10.0.0.8
===========================================================================
Persistent Routes:
None