Linux learning --- build a VPN Server and ubuntuvpn under Ubuntu

Source: Internet
Author: User

Linux learning --- build a VPN Server and ubuntuvpn under Ubuntu

Build a VPN Server in Ubuntu

What is VPN? It is a virtual private network. The function is to establish a private network on a public network for encrypted communication.

Applicable scenarios:

1. Your company network is in a LAN and cannot be accessed from outside. One day you are out on vacation and want to access the company's internal network. The Internet cannot be accessed directly. If a company's network has a host with a VPN, you can connect to this VPN host to access the company's internal network.

2. If your host is abroad, you can configure a VPN on this host, and then your computer can jump over the wall after connecting to the VPN.

3. A server (such as a game server) limits some IP addresses to connect to it. In this case, you configure a VPN. After connecting to the VPN, you can continue to access the server.

The following uses Ubuntu as an example to describe how to configure a VPN Server.

1. log on to the server with the root account


2. Install PPTPD

apt-get install pptpd


3. Edit the pptpd. conf file.

vi /etc/pptpd.conf
Uncomment the following content

localip 192.168.0.1remoteip 192.168.0.234-238,192.168.0.245
The IP address range that can be obtained after the external computer connects to the vpn through pptp and the IP address settings of the server.


4. Add an account for login

vi /etc/ppp/chap-secrets
The format is as follows:

# client server secret IP addressescqc pptpd 123456 *
The user name is specified from left to right. Server, enter pptpd, password, and specify your own. IP address. Enter. Separated by spaces.

5. Set DNS resolution and edit the pptpd-options file

vi /etc/ppp/pptpd-options
Find ms-dns, cancel the comment, and modify the DNS address.

Google DNS 8.8.8.8 and 8.8.4.4

Change to the following content:

ms-dns 8.8.8.8ms-dns 8.8.4.4
6. Enable forwarding

vi /etc/sysctl.conf
Uncomment the following content
net.ipv4.ip_forward=1
Enable kernel IP forwarding.
Update Configuration
sudo sysctl -p


7. Install iptables and set

apt-get install iptablessudo iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE
The purpose of this sentence is to immediately enable LINUX to support NAT (platinum)

8. Restart the service.

/etc/init.d/pptpd restart


9. As a result, the VPN Server is well configured.
Next, use the IP address and the VPN account and password you just set to connect to your VPN.




Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.