Linux搭建VPS***

環境:CentOS 5 i386  假設我們的VPS地址爲114.114.114.114

關閉SELinux,不然安裝完成後客戶端連接就杯具的報800錯誤

[root@localhost ~]#vim /etc/sysconfig/selinux

SELINUX=disabled

:wq

[root@localhost ~]#setenforce 0  ##上面設置的是重啓才生效,所以我們再設置一下及時生效的

[root@localhost ~]#mknod /dev/ppp c 108 0

[root@localhost ~]#echo "mknod /dev/ppp c 108 0" >> /etc/rc.local

[root@localhost ~]#cat /dev/net/tun

cat: /dev/net/tun: File descriptor in bad state(文件描述符處於錯誤狀態)  ##輸出此條說明支持tun設備

[root@localhost ~]#modprobe ppp-compress-18 && echo 'ok'

ok  ##返回此條說明支持mppe

以上都沒問題才考慮安裝PPTP

[root@localhost ~]#rpm -qa | grep ppp  ##如沒有ppp則執行yum -y install ppp即可

[root@localhost ~]#strings '/usr/sbin/pppd' |grep -i mppe | wc -l  ##輸出爲“0”則表示不支持,輸出爲“30”或更大的數字則支持

42

[root@localhost ~]#rpm -ivh http://acelnmp.googlecode.com/files/pptpd-1.3.4-1.rhel5.1.i386.rpm  ##本機爲32bit

##rpm -ivh http://acelnmp.googlecode.com/files/pptpd-1.3.4-1.rhel5.1.x86_64.rpm

##pptpd-1.4.0-1.el6.x86_64.rpm:

##ppp-2.4.5-5.el6.x86_64.rpm:

pptpd-1.3.4對應ppp-2.4.4

pptpd-1.4.0對應ppp-2.4.5

[root@localhost ~]#vim /etc/pptpd.conf

修改下面兩句:

localip 192.168.0.1 #服務端IP,不需在網卡上設定的,僅供***客戶端連接(可自定義)

remoteip 192.168.0.2-230 ##客戶端IP池(可自定義)

:wq

[root@localhost ~]#vim /etc/ppp/options.pptpd

ms-dns 8.8.8.8  ##添加DNS

require-mppe-128  ##機器支持MPPE加密的保持不變,否則註釋掉

:wq

[root@localhost ~]#vim /etc/ppp/chap-secrets

# Secrets for authentication using CHAP

# client        server  secret                  IP addresses

textuser    pptpd   textpasswd  *  ##第一個textuser爲用戶名;第二個pptpd爲服務名稱(options.pptpd配置文件裏面定義的名稱,默認爲pptpd);第三個textpasswd爲密碼;第四個爲客戶端訪問的IP範圍,*就不定義了

:wq

[root@localhost ~]#vim /etc/sysctl.conf

net.ipv4.ip_forward = 1  ##修改爲1,允許轉發

:wq

[root@localhost ~]#sysctl -p  ##使其立即生效

[root@localhost ~]#iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j SNAT --to-source `ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk 'NR==1 { print $1}'`

[root@localhost ~]#iptables -A FORWARD -p tcp --syn -s 192.168.0.0/24 -j TCPMSS --set-mss 1356

[root@localhost ~]#service iptables save

[root@localhost ~]#service iptables start

[root@localhost ~]#service pptpd start

完成,客戶端新建***連接訪問吧!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章