LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 08-04-2009, 02:54 AM   #1
scng
Member
 
Registered: Sep 2004
Location: Hong Kong
Distribution: Fedora Core 3
Posts: 53

Rep: Reputation: 15
Accessing Internet via OpenVPN


For some reasons, my neighbour country (country A), where I need to travel frequently for business purpose, blocks access of some sites.

i wish to gain full access to the Internet whenever I am in country A.

i then set up a vpn server (ubuntu) at home (country B, and no Internet restriction in country B). i wish to direct all internet access via the vpn server when i am in country A.

Code:
That's to say:


Internet (client) <==> Home router <==> VPN server <==> Home router <==> Internet (restricted sites)


i have completed the installation of vpn and can connect successfully to the vpn server from the Internet. the problem is that the connection is limited from client to the vpn server only, failed to access elsewhere (neither the Internet or File server within the intranet).

Code:
My settings:

                          <===> VPN server
Internet <==> Home router
                          <===> File server


Home subnet: 192.168.1.0
VPN subnet: 10.8.0.0

Home router private IP: 192.168.1.1
VPN server IP: 192.168.1.100 & 10.8.0.1
File server IP: 192.168.1.101

I am a newbie to networking. May I ask somebody's help to illustrate how to complete the configuration, in particular, the routing table and any things to do with the openvpn config files?

Thanks a lots!

Last edited by scng; 08-05-2009 at 08:29 PM.
 
Old 08-04-2009, 04:38 AM   #2
ccargo
LQ Newbie
 
Registered: Feb 2009
Distribution: Slackware
Posts: 20

Rep: Reputation: 1
Hi!

I got a similar setup working. In the server configuration file you should have something like

Code:
push "redirect-gateway def1"
to route all the client traffic through the server. Then to let the client access your home network, it should be enough to issue
Code:
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
where the first line enables ip-forwarding and the second adds the forwarding rule.

Hope it works out, cheers!
 
Old 08-05-2009, 08:33 PM   #3
scng
Member
 
Registered: Sep 2004
Location: Hong Kong
Distribution: Fedora Core 3
Posts: 53

Original Poster
Rep: Reputation: 15
Thanks for response!

Clients connecting thru' VPN can now access hosts in 192.168.1.0.

However, when I add [push "redirect-gateway def1"] or [push "redirect-gateway"] to server.conf, clients would not be getting access to the Internet or even other subnets.

I try to traceroute and see packet has gone through 10.8.0.1 (the openvpn) server, but then nothing else.

I have also check openvpn messages upon login and see something like:

Quote:
ROUTE default_gateway=192.168.0.1
I wonder if the gateway should be 10.8.0.1 (VPN server ip) or 192.168.1.1 (Home's route private ip).

I then try to add to server.conf:

Quote:
push "route-gateway 10.8.0.1"

and later replace it by:

push "route-gateway 10.8.0.1"
Whenever route-gateway is in place, clients cannot even ping the VPN server (10.8.0.1) or hosts in subnet (e.g. 192.168.1.101)

I guess it should be the OpenVpn server fails to route client's traffic and wonder if anything to do with iptables?
 
Old 08-10-2009, 03:55 AM   #4
ccargo
LQ Newbie
 
Registered: Feb 2009
Distribution: Slackware
Posts: 20

Rep: Reputation: 1
Hi,

I'm not sure I fully understand. Did you get access to 192.168.0.1 after adding the push-command to the server configuration file and running the two commands on the server? Or did you already have access?

Regarding the messages on startup, I don't see any similar output. However, as far as I understand it, your default gateway should be 10.8.0.1.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenVPN - LAN Without Internet tsj5j Linux - Networking 3 01-29-2007 06:11 AM
IPTables is blocking my OpenVPN internet access! eponymous Linux - Security 2 01-23-2007 01:40 PM
Merging two LANs with OpenVPN across the Internet tedcox Linux - Networking 3 12-30-2006 10:39 AM
Accessing Openvpn client through browser using port nos. jomy Linux - Networking 0 05-20-2006 06:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration