Centos 搭建 PPPoE 服務器

 

1 服務端

 

(1) 安裝pppoe,安裝完成後,會有pppoe-server命令

yum install rp-pppoe

 

安裝完成後,會在動在/etc/ppp目錄下生成pppoe-server-options文件。

 

(2) 修改服務配置文件

vi /etc/ppp/pppoe-server-options

 

# PPP options for the PPPoE server
# LIC: GPL
#  認證方式爲chap, 還可以配置爲pap方式
# win7密碼是加密的,可能不支持pap,所以測試最好是chap
require-chap
login
lcp-echo-interval 10
lcp-echo-failure 2

 

 

(3) 修改配置文件 /etc/ppp/options

vi /etc/ppp/options

 

# local    # local for chap
auth       # auth for chap
lock        # lock for chap

 

(4) 添加賬戶

(a) 若採用chap認證方式

vi /etc/ppp/chap-secrets
# Secrets for authentication using CHAP
# client        server  secret                  IP addresses
"test"          *       "12345678"                   *

 

 

(b) 若採用pap認證方式

vi /etc/ppp/pap-secrets

 

# Secrets for authentication using PAP
# client        server  secret                  IP addresses
"test"          *       "12345678"                   *

 

 

(5) 設置支持IP轉發

vi /etc/sysctl.conf
net.ipv4.ip_forward = 1  # 修改爲1

 

 

(6) 啓動pppoe

pppoe-server -I eth0 -L 192.168.11.101 -R 192.168.22.200 -N 10 -F
# -L 虛擬PPPoE接口,不是eth0的IP地址(可以不設置eth0的IP地址)
# -R 起始地址
# -N 地址個數
# -F 前臺運行,默認後臺運行

 

 

2 客戶端

 

2.1 win7 客戶端

 

(1) 添加pppoe客戶端,如果已經存在,則直接連接

 

(a) 打開網絡共享中心

 

 

(b) 設置新的連接和網絡

 

 

(2) 輸入賬號和密碼,開始連接

 

 

 

 

2.2 centos 客戶端

 

(1) 安裝 rp-pppoe 包

yum install rp-pppoe

 

(2)使用root用戶,執行 pppoe-setup 生成配置

pppoe-setup
# 按照提示輸入對應內容即可
Ethernet Interface: eth0
User name:          test
Activate-on-demand: No
DNS:                Do not adjust
Firewalling:        NONE
User Control:       yes
Accept these settings and adjust configuration files (y/n)? y
Adjusting /etc/sysconfig/network-scripts/ifcfg-ppp0
Adjusting /etc/ppp/chap-secrets and /etc/ppp/pap-secrets
  (But first backing it up to /etc/ppp/chap-secrets.bak)
  (But first backing it up to /etc/ppp/pap-secrets.bak)

Congratulations, it should be all set up!
Type '/sbin/ifup ppp0' to bring up your xDSL link and '/sbin/ifdown ppp0'
to bring it down.
Type '/sbin/pppoe-status /etc/sysconfig/network-scripts/ifcfg-ppp0'
to see the link status.

 

 

(3) 運行

[root@centos ~]# ifdown ppp0       // 停止
[root@centos ~]# ifup ppp0         // 運行
[root@centos ~]# 
[root@centos ~]# ifconfig          // 查看網口配置
ppp0      Link encap:Point-to-Point Protocol  
          inet addr:192.168.22.201  P-t-P:192.168.11.101  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1492  Metric:1
          RX packets:17 errors:0 dropped:0 overruns:0 frame:0
          TX packets:17 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3 
          RX bytes:220 (220.0 b)  TX bytes:265 (265.0 b)

 

 

(4) 查看日誌信息

[root@centos ~]# tail -f /var/log/messages
Nov 12 10:26:10 centos pppd[7389]: pppd 2.4.5 started by root, uid 0
Nov 12 10:26:10 centos pppd[7389]: Using interface ppp0
Nov 12 10:26:10 centos pppd[7389]: Connect: ppp0 <--> /dev/pts/1
Nov 12 10:26:10 centos pppoe[7390]: PPP session is 2 (0x2)
Nov 12 10:26:11 centos pppd[7389]: CHAP authentication succeeded: Access granted
Nov 12 10:26:11 centos pppd[7389]: CHAP authentication succeeded
Nov 12 10:26:36 centos pppd[7389]: local  IP address 192.168.22.201
Nov 12 10:26:36 centos pppd[7389]: remote IP address 192.168.11.101

 

 

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