ตัวอย่างการปรับแต่ง NetBSD ให้ใช้งานกับ ADSL โดยรายละเอียดความต้องการมีดังนี้
Interface มี 2 ตัวคือ rtk0 และ rtk1
ให้ rtk0 ติดต่อกับ adsl modem
ให้ rtk1 ติดต่อกับ LAN 192.168.0.0/24 โดยมี ip address 192.168.0.1
ภายใน LAN มีบริการ DHCP
ก่อนอื่นต้องปรับแต่ง modem router ให้ทำงานเป็น bridge ก่อนโดยให้เลือกการทำงานเป็นแบบ PPPoE (หมายถึง PPP ที่วิ่งบน Ethernet) สำหรับรายละเอียดให้ศึกษาคู่มือของ modem
สร้างไฟล์ ifconfig.pppoe0 โดยพิมพ์ข้อความต่อไปนี้ (บรรทัดที่ขึ้นต้นด้วย # จะเป็น comment ไม่ต้องพิมพ์ก็ได้)
create
# Mark the physical interface used by this PPPoE interface up
! /sbin/ifconfig rtk0 up
# Let $int use rkt0 as its Ethernet interface
! /sbin/pppoectl -e rtk0 $int
# Configure authentication
! /sbin/pppoectl $int myauthproto=pap 'myauthname=XXX' 'myauthsecret=YYY' hisauthproto=none
# Configure the PPPoE interface itself. These addresses are magic
# meaning we don't care about either address and let the remote
# ppp choose them.
0.0.0.0 0.0.0.1 up
ให้แก้ไขข้อมูลที่ขีดเส้นใต้โดย
- rtk0 หมายถึง Interface
- XXX หมายถึง userid ของ ADSL
- YYY หมายถึง password ของ ADSL
ทดสอบการทำงานโดยให้พิมพ์ข้อความต่อไปนี้
/etc/rc.d/network restart
pppoectl -d pppoe0
ให้สังเกตผลที่ได้ ถ้ามีคำว่า state=session หมายถึงในขณะนี้ PPPoE สามารถติดต่อได้แล้ว
กำหนดกิจกรรมที่จะต้องทำขณะเริ่ม connection และขณะ lost connection โดยสร้างไฟล์
- /etc/ppp/ip-up มีรายละเอียดดังนี้
#! /bin/sh
#add default (parameter 5 is ip address of PPPoE)
/sbin/route add default $5
#force start ipnat service
/etc/rc.d/ipnat forcestart
- /etc/ppp/ip-down มีรายละเอียดดังนี้
#! /bin/sh
#delete default (parameter 5 is ip address of PPPoE)
/sbin/route delete default $5
#force stop ipnat service
/etc/rc.d/ipnat forcestop
แล้วให้เปิดการทำงาน ifwatchd=YES ที่ rc.conf
ระบุ map ของ ipnat โดยสร้างไฟล์ /etc/ipnat.conf
map pppoe0 192.168.0.0/24 -> 0/32 portmap tcp/udp 44000:49999 mssclamp 1440
map pppoe0 192.168.0.0/24 -> 0/32 mssclamp 1440
mssclamp จะเป็นการระบการเปลี่ยนแปลง MTU ซึ่งโดยปกติ MTU ของ Ethernet จะมีค่า 1500 แต่ MTU ของ PPPoE จะมีค่า 1440 ดังนั้นการ map port จึงต้องระบุถึงความเปลี่ยนแปลงนี้ด้วย
เปิด forward port โดยเพิ่มบรรทัดต่อไปนี้ลงในไฟล์ /etc/sysctl.conf
net.inet.tcp.mss_ifmtu=1
net.inet.ip.forwarding=1
ในกรณีที่ ISP ได้กำหนดให้ระบุค่า DNS ให้ทำการสร้างไฟล์ /etc/resolv.conf มีรายละเอียดดังนี้
nameserver 203.113.15.99
nameserver 203.113.15.100
หมายเหตุ dsn ข้างต้นเป็นของ TOT
- การเปิดบริการ dhcp ให้สร้างไฟล์ /etc/dhcpd.conf มีรายละเอียดดังนี้
ddns-update-style ad-hoc;
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.10 192.168.0.254;
option domain-name-servers 203.113.15.99, 203.113.15.100;
option routers 192.168.0.1;
}
เปิดการทำงานของ dhcpd โดยเพิ่มบรรทัด dhcpd=YES ใน rc.conf แล้วให้สร้างไฟล์ /var/db/dhcpd.leases โดยพิมพ์คำสั่ง touch /var/db/dhcpd.leases
- ตรวจสอบไฟล์ rc.conf ควรมีรายละเอียดดังนี้
hostname=my-router
ifconfig_rtk1="inet 192.168.0.1/24"
dhcpd=YES
ifwatchd=YES
Ref:
http://www.netbsd.org/Documentation/network/pppoe/
http://www.netbsd.org/Documentation/network/dhcp.html