Configure vpn in ubuntu to support Internet access and ubuntuvpn

Source: Internet
Author: User
Tags get ip traceroute command

Configure vpn in ubuntu to support Internet access and ubuntuvpn

The company's development environment is LAN, and there is no problem in the company's internal use, but sometimes it does need to be used outside, such as at home, on a business trip, at this time you need to configure a vpn connection to the company's intranet. The vpn configuration is very simple, but sometimes we still need public network resources after connecting to the vpn, such as qq receiving files, querying information and so on. The vpn is disconnected and connected to the Internet. After checking the information, we can connect to the vpn, annoying. This requires that the vpn can also access the internet. In windows, this configuration is very simple. On the vpn connection attribute, change the ipv4 attribute to "automatically get IP Address" and "automatically get DNS server address. However, in linux, the route table needs to be modified.

Vpn configuration in ubuntu has a graphical interface, which is relatively simple. There are also detailed steps on the Internet. After the configuration is successful, use route-n in the terminal to check the route table.


The first option is the default route, which can match all ip addresses. That is to say, all networks finally go to the gateway 192.168.1.1 (my router gateway, access the internet) unless there is a more matched routing rule. In this way, you will understand that if you want to enable the vpn to access Internet resources, you will point all the ip rules that need to go through the vpn to the route of ppp0, and the remaining will go through the default gateway, that is, wlan0.

How can I view the net address of a vpn? After connecting to the vpn, run the ifconfig command to find the point-to-point address of ppp0, for example, 10.24.22.10. The intranet address you want to access is 10.24.2.132 ~ 10.24.3.20., Add a route. Command: routeadd-net 10.24.0.0 netmask 255.255.0.0 gw10.24.22.10 (net is 10.24.0.0, subnet mask is 255.255.0.0, Gateway is 10.24.22.10, and hop is 1 ), then reconnect to the vpn. Run the traceroute command to view the network access path. If the network is requested, the first hop is 192.168.1.1. If the vpn resource is accessed, the first hop is 10.24.22.10. In this way, the vpn can access the Internet at the same time.

Of course, you can also configure it on the GUI: network -- vpn connection -- configure vpn -- edit -- IpV4 settings -- route -- add -- enter address, subnet mask, gateway, and measurement -- select ignore automatically obtained route and only use this connection for the corresponding resources on the Network -- save.


Then reconnect to the vpn and execute route-n to view the route table, so that you can access the Intranet and Internet resources at the same time.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.