pppoe server 搭建

时间:2023-03-10 02:27:58
pppoe server 搭建

Ubuntu 上搭建 pppoe server

pppoe server 搭建

  1. sudo apt-get install pppoe
  2. $ cat /etc/ppp/pppoe-server-options
# PPP options for the PPPoE server
# LIC: GPL
require-chap
auth
lcp-echo-interval 10
lcp-echo-failure 2
logfile /tmp/pppd.log
  1. /etc/ppp/options 编辑几个地方
ms-dns 223.5.5.5
-pap
+chap
  1. cat chap-secrets 在其中添加用户名和密码
"admin"	*	"admin"         *
  1. 启动 pppoe-server
sudo pppoe-server -I eth0 -L 172.25.1.1 -R 172.25.1.100 -N 10

这里我在虚拟机里添加了两张网卡,其中一张正常 NAT 上网,另一张网卡设置为 host only,静态 IP。用于拨号。

6. 添加 iptables 设置之后就可能拨号成功,并正常访问外网。

sudo iptables -A POSTROUTING -t nat -s 172.25.1.0/24 -j MASQUERADE

用路由器搭建 pppoe server

用 PC 搭建浪费一台电脑,不如直接在路由器上用 OpenWrt 来搭建一个 PPPoe server

pppoe server 搭建

  1. 添加软件源

    cat /etc/opkg.conf
dest root /
dest ram /tmp
lists_dir ext /var/opkg-lists
option overlay_root /overlay
src/gz packages http://downloads.openwrt.org/barrier_breaker/14.07/ramips/mt7620a/packages/packages
src/gz oldpackages http://downloads.openwrt.org/barrier_breaker/14.07/ramips/mt7620a/packages/oldpackages
  1. 更新软件包
opkg update
  1. 安装 rp-pppoe
opkg install rp-pppoe-server
  1. cat /etc/ppp/options
#debug
logfile /dev/null
noipdefault
noaccomp
nopcomp
nocrtscts
lock
maxfail 0
lcp-echo-failure 5
lcp-echo-interval 1
  1. cat /etc/ppp/pppoe-server-options
# PPP options for the PPPoE server
# LIC: GPL
require-chap
auth
lcp-echo-interval 10
lcp-echo-failure 2
logfile /tmp/pppd.log
  1. 启动 pppoe-server
pppoe-server -k -I br-lan -L 172.25.1.1 -R 172.25.1.100 -N 10
  1. 配置 iptables 转发。但这我里不起作用,拨号成功后无法通过这个 server 上外网。
iptables -t nat -A POSTROUTING -s 172.25.1.0/24 -j MASQUERADE

这里不能上外网,可能是因为路由器本身的一些设置问题。还没有搞清楚 。