Centos 串連VPN伺服器

來源:互聯網
上載者:User

Centos 串連VPN伺服器

環境:centos6.4
1.安裝ppp pptp pptp-setup

yum install ppp pptp pptp-setup

2.建立VPN串連

pptpsetup --create tunnelname --server ip地址 --username 使用者名稱 --password 密碼

檔案會出現在/etc/ppp/peers/下面, 檔案名稱就是tunnelname, 也就是–create後面的參數.

3.然後

cp /usr/share/doc/ppp-2.4.5/scripts/pon /usr/sbin/
cp /usr/share/doc/ppp-2.4.5/scripts/poff /usr/sbin/
chmod +x /usr/sbin/pon
chmod +x /usr/sbin/poff

4.配置pptp

4.1 編輯/etc/pptpd.conf,命令如下

vim /etc/pptpd.conf

將 #localip 192.168.0.1 #remoteip 192.168.0.234-238,192.168.0.245 修改成 localip 192.168.0.1 remoteip 192.168.0.234-238,192.168.0.245 即將這兩行第一個字元“#”去掉,儲存退出

4.2 編輯/etc/ppp/options.pptpd,命令如下

cp /etc/ppp/options.pptpd /etc/ppp/options.pptpd.bakvim /etc/ppp/options.pptpd

添加 ms-dns 8.8.8.8 ms-dns 8.8.4.4

4.3設定使用pptp的使用者名稱和密碼

cp /etc/ppp/chap-secrets   /etc/ppp/chap-secrets.bakvim /etc/ppp/chap-secrets

根據您的需要添加帳號,每行一個。按照: “使用者名稱 pptpd 密碼 ip地址”的格式輸入,每一項之間用空格分開,例如:kuro pptpd 123456 * (*表示所有IP)

5.修改核心設定,使其支援轉寄

vim /etc/sysctl.conf

將net.ipv4.ip_forward=0 改成net.ipv4.ip_forward=1

執行以下命令使修改後的核心生效

sysctl -p

這裡有時會遇到一些問題,

解決方案如下: 修複modprobe的:

rm -f /sbin/modprobe ln -s /bin/true /sbin/modprobe

修複sysctl的:

rm -f /sbin/sysctl ln -s /bin/true /sbin/sysctl

然後運行

/sbin/sysctl -p

由於沒有啟用防火牆,所以此處省略防火牆轉寄等過程,文章末尾連結會有相關介紹。

6.撥vpn pon vpn串連名稱(自訂)

7.查看是否串連 ifconfig 有ppp0即成功

查看/var/log/message,是否啟動成功了, 如果未成功, 看是什麼錯誤 可能出現的問題:

1.如果是這個錯誤: MPPE required but peer negotiation failed, 說明服務端不支援MPPE加密,pptpsetup時不需要使用–encrypt選項。可以手工修改/etc/ppp/peers/tunnelname 檔案, 去掉require-mppe-128

2.如果是這個錯誤: LCP terminated by peer (MPPE required but peer refused), 說明服務端要求MPPE加密,但是用戶端不支援。解決方案正好相反,往/etc/ppp/peers/tunnelname 檔案添加一行require-mppe-128

8.如果你能ping通ppp0IP,但ping同網段其他IP,請添加路由 route add -net 172.16.1.0 netmask 255.255.255.0 dev ppp0

9.中斷連線 poff vpn串連名稱(自訂)

參考連結 https://bbs.aliyun.com/simple/?t163732.html http://www.cnblogs.com/doomsword/p/3248910.html http://blog.51yip.com/linux/1620.html https://zhidao.baidu.com/question/292074910.html http://viong.blog.51cto.com/844766/276025 http://www.linuxfly.org/post/641/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.