Install RP-PPPoE

 

sudo apt-get install ppp

wget https://dianne.skoll.ca/projects/rp-pppoe/download/rp-pppoe-3.13.tar.gz

tar zxvf rp-pppoe-3.13.tar.gz

cd rp-pppoe-3.13/src

./configure

make

sudo make install

 

configure file

 

sudo nano /etc/ppp/pppoe-server-options

 

require-chap

auth

lcp-echo-interval 10

lcp-echo-failure 2

ms-dns 8.8.8.8

ms-dns 8.8.4.4

logfile /var/log/pppd.log

原始是 require-pap login 要改成 require-chap authms-dns 則是傳送 dns server user 設定。

 

User setup

sudo nano chap-secrets

# Secrets for authentication using CHAP

# client server  secret         IP addresses

"user1"  *         "123456"    *

 

client 為使用者名稱

secret 為使用者密碼

 

 

Enable internet connection

sudo su
1)開啟IP轉發,這樣eth0的包才會被允許轉發到eth1

echo 1 > /proc/sys/net/ipv4/ip_forward

2)將eth1出向包的源地址進行修改

#uncomment net.ipv4.ip_forward=1 in /etc/sysctl.conf for permanent settings

iptables -A POSTROUTING -t nat -s 10.10.10.0/24 -j MASQUERADE


 

 

#start pppoe server

sudo pppoe-server -I eno1 -L 10.10.10.1 -R 10.10.10.100 -N 100

-I 為網卡名稱,預設為 eth0

-L 為派發給使用者的 gateway ip

-R 為派發給使用者的 ip 起始位置。

-N 允許同時上線的使用者。

 

#stop pppoe server

sudo killall pppoe-server

 

 

 

簡單的腳本測試

NET_NAME= enp0s31f6

IP_BASE=10.10.10

#sudo su

 

killall pppoe-server

sleep 1

 

echo 1 > /proc/sys/net/ipv4/ip_forward

 

iptables -A POSTROUTING -t nat -s ${IP_BASE}.0/24 -j MASQUERADE

sleep 1

 

echo "---pppoe-server -I  ${NET_NAME}  -L ${IP_BASE}.1 -R ${IP_BASE}.100 -N 100 ---"

 

pppoe-server –I  ${NET_NAME} -L ${IP_BASE}.1 -R ${IP_BASE}.100 -N 100

 

 

 

若成功會顯示

root@test-desktop:/home/share# ifconfig ppp0

ppp0      Link encap:Point-to-Point Protocol 

          inet addr:10.10.10.1  P-t-P:10.10.10.100  Mask:255.255.255.255

          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1492  Metric:1

          RX packets:146432 errors:0 dropped:0 overruns:0 frame:0

          TX packets:159257 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:3

          RX bytes:141326705 (141.3 MB)  TX bytes:145481283 (145.4 MB)

 

 

 

 

Debug 1

$ ./configure

checking for gcc... no

checking for cc... no

checking for cl.exe... no

configure: error: in `/home/enos/rp-pppoe-3.12/src':

configure: error: no acceptable C compiler found in $PATH

See `config.log' for more details

解決方式: sudo apt-get install gcc

 

Debug 2

checking for Linux 2.4.X kernel-mode PPPoE support... yes

configure: WARNING: *** Oops!  I couldn't find pppd, the PPP daemon anywhere.

configure: WARNING: *** You must install pppd, version 2.3.10 or later.

configure: WARNING: *** I will keep going, but it may not work.

configure: WARNING: *** Oops.  I cannot figure out what version of pppd you have.

configure: WARNING: *** All I got back was ''

configure: WARNING: *** I will keep going, but it may not work.

解決方式: sudo apt-get install ppp

Debug 3

WINDOWS 可以撥通連線 但在UBUNTU上跑pppoeconf 會失敗問題
/etc/ppp/pppoe-server-options 拿掉
require-chap

auth

不認密碼試試

 

 

Debug 4

PAP的使用者名稱稱(pap驗證的ID、密碼),不是任意的,必須與server系統的一個使用者名稱、密碼一致。

CHAP的使用者名稱稱是任意的,沒有限制的。

 

參考

https://jyhshin.pixnet.net/blog/post/47469696-ubuntu-pppoe-server

https://blog.richliu.com/2018/06/29/2298/ubuntu-pppoe-server-build

https://www.itread01.com/content/1548768966.html

 

 

 

撥接測試
參考
http://note.drx.tw/2008/08/networkpppoe-adsl.html

 

若有問題可以抓封包看看

$sudo apt-get install wireshark

 

 

    文章標籤

    pppoe

    全站熱搜

    立你斯 發表在 痞客邦 留言(0) 人氣()