NAT in FreeBSD
Berikut tahapan membuat NAT dengan FreeBSD .
1. Masuk ke direktori untuk mengkompile kernel.
root@tsubasa :/# cd /usr/src/sys/i386/conf
2. Buatlah konfigurasi kernel untuk mengaktifkan pf
root@tsubasa :# cp GENERIC PF
root@tsubasa :# ee PF
Kemudian tambahkan line berikut
#Untuk NAT################################
options IPFIREWALL
options IPDIVERT
options IPFIREWALL_DEFAULT_TO_ACCEPT
options IPFIREWALL_VERBOSE
#Untuk PF#################################
device pf
device pflog
device pfsync
options ALTQ
options ALTQ_CBQ # Class Bases Queuing (CBQ)
options ALTQ_RED # Random Early Detection (RED)
options ALTQ_RIO # RED In/Out
options ALTQ_HFSC # Hierarchical Packet Scheduler (HFSC)
options ALTQ_PRIQ # Priority Queuing (PRIQ)
options ALTQ_NOPCC # Required for SMP build
#######——CUT—###############################
3. Kompile Kernel
root@tsubasa : # config PF
root@tsubasa : # cd ../PF
root@tsubasa : # make depend
root@tsubasa : # make && make install
4. Konfigurasi NAT di pf.conf
root@tsubasa : # ee /etc/pf.conf
Tambahkan atau ubah beberapa line dengan berikut :
ext_if = "x10" ## Interface untuk IP Public
int_if = "x11"
##Misal IP yang akan diNAT adalah 192.168.0.58
nat on $ext_if from 192.168.0.58 to any -> ($ext_if)
##Misal semua IP dari local diNAT
nat on $ext_if from any to any -> ($ext_if)
5. Simpan pf.conf tersebut
6. Buka rc.conf
root@tsubasa : # ee /etc/rc.conf
Kemudian tambahkan line berikut :
######CUT HERE########################################
pf_enable="YES" # Enable PF (load module if required)
pf_rules="/etc/pf.conf" # rules definition file for pf
pf_flags="" # additional flags for pfctl startup
pflog_enable="YES" # start pflogd(8)
pflog_logfile="/var/log/pflog" # where pflogd should store the logfile
pflog_flags="" # additional flags for pflogd startup
#################################################
7. Restart Komputer
root@tsubasa : # reboot
