2018年1月16日 星期二

Raspberry Pi - 架設PPPoE server

         ----------------------------------------------
         |        eth0          |         eth1        |
       LAN PC                 Router                WAN
  ip: 10.1.1.10          eth0: 10.1.1.1
  gw: 255.255.255.0      eth1: DHCP

1. 安裝pppoe套件
$ sudo apt-get install pppoe
2. /etc/ppp/options,無需修改 3. 修改/etc/ppp/pppoe-server-options
auth
require-chap
default-mru
default-asyncmap
lcp-echo-interval 30
lcp-echo-failure 5
ms-dns 168.95.1.1
ms-dns 168.95.1.10
noipdefault
noipx
nodefaultroute
require-chap: 使用chap認證方式,帳號密碼需加於/etc/ppp/chap-secrets require-pap: 使用pap認證方式,帳號密碼需加於/etc/ppp/pap-secrets ms-dns: DNS伺服器位址 +ipv6: 如需支持IPv6 4. 設置chap認證方式的帳號密碼,修改/etc/ppp/chap-secrets
# Secrets for authentication using CHAP
# client        server  secret                  IP addresses
user * 1234 *
5. 啟用pppoe-server
sudo pppoe-server -I eth0 -L 10.1.1.1 -R 10.1.1.10-20
-I: 設置綁定的介面 -L: 設置綁定介面的位址 -R: 設置pppoe-server所分配的位址,可用"-"來設置範圍 6. 啟用IPv4 forwarding功能
$ sudo bash -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
7. 設置iptables,啟用DNAT功能
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
8. eth1介面的位址,在網路線插入時,dhcpcd會自動啟用去取得位址
$ ps -aux | grep dhcp
root       314  0.0  0.2   2884  1988 ?        Ss   14:04   0:00 /sbin/dhcpcd -q -b
9. 使用Windows寬頻連線測試
10.1 建立寬頻連線後,pppoe server會新增一個ppp0連線,位址為10.1.1.1
10.2 建立寬頻連線後,PC會取得位址為10.1.1.10,DNS位址如設置的168.95.1.1和8.8.8.8
11. 在使上用wireshark抓取封包,過濾條件為"pppoed || pppoes"
12. 參考來源 https://linux.die.net/man/8/pppoe-server https://linux.die.net/man/8/pppd

沒有留言:

張貼留言