大家都知道,宽带上网有三种接入方式,就是我们在设置路由器时,根据运营商的接入方式,设置不同的上网方法。这三种接入方式分别是:

运营商是怎么通过PPPOE拨号认证服务器,让我们使用电脑或路由器拨号的方式达到共享上网的目的呢?在这里,我搭建了实验环境,并用一张简单的网络拓扑结构图进行说明:

linux如何关闭系统的pppoe进程(shell脚本在CentOS完成PPPOE拨号服务器)(1)

PPPOE拨号认证服务器实验网络拓扑图

想像一下:在这里,如果把8口路由器变成48口或更多呢?那是不是实现一幢大楼的宽带接入,如果网络端口更多呢?那么就能发展成一个城域网或是一个校园网……

前面只是简单的抛砖引玉,说说自己理解的网络组成结构!那么我的目的是用shell脚本建立一台PPPOE 拨号认证服务器,达到学习和测试的目的!

就像上图:如果我们建立了PPPOE拨号认证服务器,在交换机的位置是不是可以用一台路由器,通过自建的pppoe帐号,设置好上网方式达到共享上网的目的?

参考文档:https://www.linuxidc.com/Linux/2017-02/140509.htm

【shell脚本程序建立PPPOE 认证服务器代码】

# ----------------------------------------------------------------------------- # | Samba Server Shell scripts Create..... # ----------------------------------------------------------------------------- # | Copyright (c) 2020 Shanghai DuoLuo information Co.,LTD All rights reserved. # ----------------------------------------------------------------------------- # | Author: andy.wang <14918097@qq.com> # ----------------------------------------------------------------------------- #!bai/bin/bash #cd /mnt/smb1/Linux_Server/pppoeserver echo ---------------------------Set User Name----------------------------------- user1=test01 user2=test02 pw1="test2020" pw2="test2020" # PPPOE认证方式二种,分别是chap、pap ,修改不同的文件,本shell脚本是二种都改 tempNIC=$(awk 'BEGIN {max = 0} {if ($2 0 > max 0) {max=$2 ;content=$0} } END {print $1}' /proc/net/dev ) netnic=$(echo ${tempNIC%:*}) echo "" echo "---------------User&Password&Group-------------------" echo "PPPOE User: "$user1" password: "pw1" echo "PPPOE User: "$user2" password: "pw2" echo "" echo "--------------- 判断是否安装有Samba组件---------------" if [ -f "/usr/sbin/pppoe-server" ];then echo "rp-pppoe-3.11-7.el7.x86_64 is install...." else yum install rp-pppoe fi echo "--------------- 建立备份文件---------------" cp -f /etc/ppp/pppoe-server-options /etc/ppp/pppoe-server-optionsbak cp -f /etc/ppp/options /etc/ppp/optionsbak cp -f /etc/ppp/chap-secrets /etc/ppp/chap-secretsbak cp -f /etc/ppp/pap-secrets /etc/ppp/pap-secretsbak cp -f /etc/sysctl.conf /etc/sysctl.confbak echo "---------------修改配置文件vim /etc/ppp/pppoe-server-options----------------" if [ $requiresecrets="chap" ];then sed -i 's/require-pap/require-chap/g' /etc/ppp/pppoe-server-options else echo "Server require-chap" fi sed -i '$a ['"$share01"']' vi /etc/ppp/options if [ $requiresecrets="chap" ];then sed -i 's/require-pap/require-chap/g' /etc/ppp/pppoe-server-options else echo "Server require-chap" fi #echo "---------------添加帐号密码 chap-secrets OR pap-secrets---------------" #if [ $requiresecrets="chap" ];then #else #fi if cat '/etc/ppp/chap-secrets' | grep "$user1" > /dev/null then echo "$user1 account is exist,check $user1 password!" else sed -i '$a '" $user1 "' * '"$pw1"' *' /etc/ppp/chap-secrets fi if cat '/etc/ppp/chap-secrets' | grep "$user2" > /dev/null then echo "$user2 account is exist,check $user2 password!" else sed -i '$a '" $user2 "' * '"$pw2"' *' /etc/ppp/chap-secrets fi clean cat /etc/ppp/chap-secrets if cat '/etc/ppp/pap-secrets' | grep "$user1" > /dev/null then echo "$user1 account is exist,check $user1 password!" else sed -i '$a '" $user1 "' * '"$pw1"' *' /etc/ppp/pap-secrets fi if cat '/etc/ppp/pap-secrets' | grep "$user2" > /dev/null then echo "$user2 account is exist,check $user2 password!" else sed -i '$a '" $user2 "' * '"$pw2"' *' /etc/ppp/pap-secrets fi clean cat /etc/ppp/pap-secrets echo -------修改配置文件/etc/sysctl.conf----------- if cat '/etc/sysctl.conf' | grep "net.ipv4.ip_forward=1" > /dev/null then echo "net.ipv4.ip_forward=1 alreary adding...... OK" else sed -i '$a net.ipv4.ip_forward=1' /etc/sysctl.conf fi pppoe-server -I 网卡2名称 -L 192.168.111.101 -R 192.168.22.200 -N 100 -F echo ----------------------..Finish...----------------------

作者:王维翰,资深IT运维工程师,具备20多年IT及相关技术支持,为上海近千家中小企业、家庭用户提供过专业的IT技术支持服务;曾多次获“中小企业十佳项目经理”、“中小企业IT专家”……!

,