--------Introduction/Disclaimer------------ This document may be modified, reproduced, and distributed free of charge, as long as the "INTRODUCTION/DISCLAIMER" notice and the original author's name are both included. Also, please go to http://www.freebsd.org/copyright/index.html for FreeBSD copyright information. Created 03-April-2003 - aka ded1 E-mail: ded1@MyBSD.org.my WWW: http://www.ded1.org *Sebarang komen/idea/pertanyaan dialu-alukan* Ini adalah tutorial cara untuk konfigurasi router/gateway server menggunakan FreeBSD 4.7-RELEASE ----------------------------------- Bahan-bahan: i). 2 NIC (3com 3C905B TX) ii). x86 machine yang siap diinstall FreeBSD 4.7-RELEASE iii). 1 Switch iv). UTP cable 1. Bagi FreeBSD 4.7-RELEASE, ipfilter sudah siap diinstall ke dalam kernel. 2. Anda cuma perlu masukkan line berkaitan ipf pada kernel config. Seperti berikut: # IPF FIREWALL options IPDIVERT options IPFILTER options IPFILTER_LOG options IPTUNNEL options IPSTEALTH options IPSEC options IPSEC_ESP options IPSEC_DEBUG 3. Kemudian recompile kernel FreeBSD anda (rujuk http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-building.html) dan reboot. 4. Dalam kes ini mesin router anda mesti mempunyai 2 network kad dengan 2 IP (1 public ip & 1 internal IP) Router anda mempunyai ip statik 192.168.0.20 (public ip) dan statik internal IP (10.10.10.1) xl0 (network kad no.1 dengan public IP) xl1 (network kad no.2 dengan internal IP) 5. Selepas itu, masukkan line berikut ke /etc/rc.conf gateway_enable="YES" ifconfig_xl0="192.168.0.20 netmask 255.255.255.0" ifconfig_xl1="inet 10.10.10.1 netmask 255.0.0.0" router_flags="-q" router="/sbin/routed" router_enable="YES" ipfilter_enable="YES" ipfilter_flags="" ipfilter_program="/sbin/ipf -Fa -v" ipfilter_rules="/etc/ipf.rules" ipnat_enable="YES" ipnat_program="/sbin/ipnat" ipnat_rules="/etc/ipnat.rules" ipnat_interface="xl0" 6. Pastikan machine anda diinstall dengan route daemon (routed) 7. Sekarang sila buat rules untuk ipf anda (cipta nama file /etc/ipf.rules) seperti berikut: pass in all pass out all pass in on lo0 all pass in quick on xl0 from any to any pass in quick on xl1 from any to any pass out quick on xl0 from any to any pass out quick on xl1 from any to any 8. Kemudian buat pula rules IPNAT (/etc/ipnat.rules) seperti berikut: map xl0 10.0.0.0/8 -> 192.168.0.20/32 portmap tcp/udp 10000:60000 map xl0 10.0.0.0/8 -> 192.168.0.20/32 map xl1 192.168.1.0/24 -> 0/32 portmap tcp/udp 40000:65000 map xl1 192.168.1.0/24 -> 0/32 9. Maknanya disini semua mesin client dalam subnet anda menggunakan IP 10.10.10.0/24 dan di bridge ke IP public router (192.168.0.20). Semua packet dari subnet 10.10.10.0/24 akan di forward ke 192.168.0.20 10. Kemudian jalankan arahan ini untuk route IP. # route -n add -net 10 -netmask 255.0.0.0 192.168.0.20 -static 11. Flush network. 12. ping localhost (kedua-dua NIC, gateway upstream, ip client & internet) jika semuanya menunjukkan tindakbalas positif, maka siap ! 13. jalankan arahan berikut untuk melihat status network interface anda. # ifconfig -a 14. Sekian.