When synchronizing data across computer rooms, VPN links are often used because of the high security. Online on this aspect of the article, I really did not find that I want, is too simple, Daniel do not want to write it, or too difficult to do it?
The following example illustrates the establishment and use of VPN links
First, install the VPN server on the remote servers
The new CentOS, the source has included the pptpd, so there is no need to, direct yum install PPTPD, on the line.
Second, client PPTP installation configuration
1, install PPP PPTP Pptp-setup
# Yum Install PPP PPTP Pptp-setup
2, create a VPN connection
# pptpsetup--create Test--server IP Address
--username Test--password Test--encrypt
3, loading module
# modprobe Ppp_mppe
4, Connect VPN connection
[root@localhost peers]# PPPD Call Test//Here's test to create the VPN connection above
If you report the following error:
Using Interface Ppp0
Connect:ppp0 <-->/DEV/PTS/3
CHAP Authentication Succeeded
LCP terminated by peer (MPPE required but peer)
Modem Hangup
Workaround:
# vim/etc/ppp/peers/test//test is the connection created above
File tail, plus the following
require-mppe-128
If you report the following error:
Refusing MPPE stateful mode offered by peer
MPPE Required but peer negotiation failed
Workaround:
Indicates that the server side does not support MPPE encryption and Pptpsetup does not need to use the--encrypt option. Or get rid of the top, require-mppe-128.
5, Connection successful
# ifconfig |grep PPP
Ppp0 Link Encap:point-to-point Protocol
# route
Kernel IP Routing Table
Destination Gateway genmask Flags Metric Ref use Iface
Li684-32.member 192.168.10.1 255.255.255.255 UGH 0 0 0 eth0
192.168.0.100 * 255.255.255.255 UH 0 0 0 ppp0
192.168.10.0 * 255.255.255.0 U 0 0 0 eth0
192.168.122.0 * 255.255.255.0 U 0 0 0 virbr0
link-local * 255.255.0.0 U 1002 0 0 eth0
Default 192.168.10.1 0.0.0.0 UG 0 0 0 eth0
After the connection succeeds, the client and the server will have something like ppp0.
6, in the client to add routing, implementation of the client, the server can access each other
# route add-net 192.168.0.0 netmask 255.255.255.0 Dev ppp0
The successful route is as follows:
[Root@localhost tank]# Route
Kernel IP Routing Table
Destination Gateway genmask Flags Metric Ref use Iface
Li684-32.member 192.168.10.1 255.255.255.255 UGH 0 0 0 eth0
192.168.0.100 * 255.255.255.255 UH 0 0 0 ppp0
192.168.0.0 * 255.255.255.0 U 0 0 0 ppp0//This one is just added.
192.168.10.0 * 255.255.255.0 U 0 0 0 eth0
192.168.122.0 * 255.255.255.0 U 0 0 0 virbr0
link-local * 255.255.0.0 U 1002 0 0 eth0
Default 192.168.10.1 0.0.0.0 UG 0 0 0 eth0
To this side, the link has been built, the following is the focus of this article.
Third, take MySQL as an example, test the VPN link
1, authorize the test database for native and remote servers
Mysql> grant all privileges in test.* to test@ ' 192.168.0.% ' identified by ' 123456 ';
mysql> flush Privileges;
To be aware here, I authorize the LAN IP
2, remote MySQL connection in the local computer
The image above 192.168.0.20 is the client VPN connection to the server, the client-generated virtual IP
The image above 192.168.0.100 is the client VPN connection to the server, the virtual IP generated at the server
These can be found in the configuration file pptpd.conf on the VPN server.
The code is as follows |
Copy Code |
# mysql-u Test-p-H 192.168.0.100/native connection remote IP
# mysql-u Test-p-H 192.168.0.20/server connection native 0 |