Centos 搭建 PPPoE 服务器

r囧r小猫 2022-04-12 09:46 1461阅读 0赞

1 服务端

(1) 安装pppoe,安装完成后,会有pppoe-server命令

  1. yum install rp-pppoe

安装完成后,会在动在/etc/ppp目录下生成pppoe-server-options文件。

(2) 修改服务配置文件

  1. vi /etc/ppp/pppoe-server-options
  2. # PPP options for the PPPoE server
  3. # LIC: GPL
  4. # 认证方式为chap, 还可以配置为pap方式
  5. # win7密码是加密的,可能不支持pap,所以测试最好是chap
  6. require-chap
  7. login
  8. lcp-echo-interval 10
  9. lcp-echo-failure 2

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

  1. vi /etc/ppp/options
  2. # local # local for chap
  3. auth # auth for chap
  4. lock # lock for chap

(4) 添加账户

(a) 若采用chap认证方式

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

(b) 若采用pap认证方式

  1. vi /etc/ppp/pap-secrets
  2. # Secrets for authentication using PAP
  3. # client server secret IP addresses
  4. "test" * "12345678" *

(5) 设置支持IP转发

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

(6) 启动pppoe

  1. pppoe-server -I eth0 -L 192.168.11.101 -R 192.168.22.200 -N 10 -F
  2. # -L 虚拟PPPoE接口,不是eth0的IP地址(可以不设置eth0的IP地址)
  3. # -R 起始地址
  4. # -N 地址个数
  5. # -F 前台运行,默认后台运行

2 客户端

2.1 win7 客户端

(1) 添加pppoe客户端,如果已经存在,则直接连接

(a) 打开网络共享中心

2018120223233114.png

(b) 设置新的连接和网络

20181202232353416.png

(2) 输入账号和密码,开始连接

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTE4NTc2ODM_size_16_color_FFFFFF_t_70

2.2 centos 客户端

(1) 安装 rp-pppoe 包

  1. yum install rp-pppoe

(2)使用root用户,执行 pppoe-setup 生成配置

  1. pppoe-setup
  2. # 按照提示输入对应内容即可
  3. Ethernet Interface: eth0
  4. User name: test
  5. Activate-on-demand: No
  6. DNS: Do not adjust
  7. Firewalling: NONE
  8. User Control: yes
  9. Accept these settings and adjust configuration files (y/n)? y
  10. Adjusting /etc/sysconfig/network-scripts/ifcfg-ppp0
  11. Adjusting /etc/ppp/chap-secrets and /etc/ppp/pap-secrets
  12. (But first backing it up to /etc/ppp/chap-secrets.bak)
  13. (But first backing it up to /etc/ppp/pap-secrets.bak)
  14. Congratulations, it should be all set up!
  15. Type '/sbin/ifup ppp0' to bring up your xDSL link and '/sbin/ifdown ppp0'
  16. to bring it down.
  17. Type '/sbin/pppoe-status /etc/sysconfig/network-scripts/ifcfg-ppp0'
  18. to see the link status.

(3) 运行

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

(4) 查看日志信息

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

发表评论

表情:
评论列表 (有 0 条评论,1461人围观)

还没有评论,来说两句吧...

相关阅读