Build a virtual private network

Source: Internet
Author: User

Online tutorials say more than a lot of said less, it depends on how you find. This chapter is a personal note:)

Build the Environment:

1. Testing the environmental requirements of the building

#cat/dev/net/tun
If this instruction shows the result as the following text, it is indicated by: Cat:/dev/net/tun:file Descriptor in Bad State 2. Installing PPTP
apt-get Install pptpd

3. Edit Vi/etc/pptpd.conf

The IP set in this place will be used later .... Attention.... '

10.100. 0.1    10.100. 0.2-Ten

localipis the IP address of the server after the VPN is connected, and the IP remoteip address that the client can assign.

4. Edit Vi/etc/ppp/pptpd-options

You need to change the ms-DNS option in which theVPN client is assigned the DNS server address Ms8.8. 8.8   Ms8.8. 4.4  

Resolution: Ms-dns 8.8.8.8, Ms-dns 8.8.4.4 is a DNS server that uses Google.

5. Edit Vi/etc/ppp/chap-secrets

the user name and password for the VPN are shown in the comments in the file, the first column is the user name, the second column is the name (default write pptpd, if changed in the pptpd-options file, note the consistency here), the third column is the password, the fourth column is the IP Limit (Do not restrict write *"ys1995. " *

6. We need to restart the PPTPD service for the new configuration to take effect

/ETC/INIT.D/PPTPD restart

At this point, if we establish a connection, we will find that in addition to the resources that can access the server, the rest of the content inside and outside the Internet is inaccessible. If you need to access these things, we need to set up further: first, open ipv4 forward . The method is to modify /etc/sysctl.conf , to find a line similar to the following and uncomment their comments ( *.ipv4.* = 1 all to remove the comment OH):

7. Edit Vi/etc/sysctl.conf

Uncomment the following: (if there is a problem bar,   *.ipv4.* = 1      Remove the comment) net.ipv4.ip_forward=1

To make the configuration effective:

Sysctl-p

Role: Modify the kernel settings to support forwarding

Sometimes, after this setup, the client machine will be able to surf the internet (I'll do it on the virtual machine). But I still can't access the network after doing this on the server in the lab, so we need to build one NAT . Here we use the powerful iptables to build NAT. First, install first iptables :

8. Add iptables forwarding rules and more

Start Iptables and Nat forwarding, it's critical.

1. Installing iptables

apt-get intall iptables

2. For the client to successfully connect to the VPN server, the host firewall is also required to open the VPN port (default is 1723)

    1723-1723--j ACCEPT

3. We then add a rule to the NAT table:

Set iptables NAT Forwarding

192.168.0.0/24 -o eth0-j Masquerade

The settings here are related to the previous/etc/pptpd.conf, in detail: http://www.dabu.info/centos6-4-structures-pptp-vpn.html Fourth step: Start PPTP VPN service and Iptables

4. After this operation, the client machine should be able to surf the Internet. However, just like this, iptables the rule will be cleared at the next reboot, so we need to save it by using the iptables-save command:

Iptables-save >/etc/iptables-rules

Follow the tutorials and you should be here.

5. Edit Vi/etc/network/interfaces

Find the Eth0 section, and at the end of the Eth0 setting, add the following sentence: Pre-up Iptables-restore </etc/iptables-rules

but I do not have this eth0 in my file, it is estimated that the network card name is not the same, you can ifconfig view

Details available: http://www.dabu.info/centos6-4-structures-pptp-vpn.html

  

6. Set the MTU to ensure that too large packets are not discarded (this can not be done)  

192.168. 0.0/ -P TCP--syn-i ppp+-j TCPMSS--set1300

    

9. Start the service

/ETC/INIT.D/PPTPD restart

Thank:

http://octree.me/buid-vpn-on-ubuntu/

Http://www.dabu.info/centos6-4-structures-pptp-vpn.html

Http://blog.sina.com.cn/s/blog_6797a6700100mhnl.html

http://blog.fens.me/ubuntu-vpn-pptp/

Build a virtual private network

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.