Pengen Punya WebSite instan kualitas intan ?

Showing posts with label FreeBSD. Show all posts
Showing posts with label FreeBSD. Show all posts

Saturday, March 19, 2011

konfigurasi sederhana freebsd sebagai router gateway

ini juga....migrasi catatan jaman SMA dari http://maz-zoga.net84.net


******************************************************************    
#
#Konfigurasi Sederhana FreeBSD sebagai Router gateway
#
******************************************************************
ni dokumentasi aku waktu PRAKERIN di TimeExellindo Jogja.Setelah utak-utik berkali-kali dan berhari-hari,trus ma dibantu oleh Mas-Mas di sini & temen-temen PSG (da Muklis, Yeyen, and Yuning, serta da temen-temen laen dari Jogja),tidak lupa da Mbah Google,akhirnya Alhamdulillah aq mulai sedikit paham dan akhirnya aku buat dokumentasi, Biar q ga lupa dan utk berbagi kepada temen-temen yg membutuhkan.Tapi ni masih sederhana karena aq juga masih baru belajar.Jika ada yang kurang aku minta saran dari temen-temen yang sedia utk mengoreksi.
nah, abis selesai install FreeBSD, lihat NIC yang terdeteksi…
moklet_psg#ifconfig
(punya aku yang d sini terdeteksi dc0 dan dc1)
na di sini dc0 –>utk ippublic dan dc1 –>utk iplocal
kemudian konfigurasi pada file /etc/rc.conf
##################################################################
/etc/rc.conf
——————————————————————
### pasang ip pada interface ###
ifconfig_dc0=”202.91.11.226 netmask 255.255.255.248″
ifconfig_dc1=”192.168.1.1 netmask 255.255.255.0″
### gateway ###
gateway_enable=”YES”
defaultrouter=”202.91.11.225″
### options ###
inet_enable=”YES”
sshd_enable=”YES”
usbd_enable=”YES”
pf_enable=”YES”
pf_rules=”/etc/pf.conf”
#################################################################
setelah itu, coba ping 192.168.1.1 bila berhasil,
lanjutkan ping ke 202.91.11.226
dan 202.91.11.*** (gateway)
bila belum berhasil bersabar saja dan coba cek konfigurasi sebelumnya, bila belum berhasil juga, coba tanya Mbah google :) n ber-do’a minta petunjuk kepada yang Maha Mengetahui Segalanya. :)
jika sudah, dilanjutkan dengan pasang DNS, konfigurasinya terletak pada file /etc/resolv.conf
### dns ############################################################ 
nameserver 202.91.8.***
nameserver 202.91.*.***
####################################################################
simpan, dan restart konfigurasi
moklet_psg# sh /etc/netstart
lalu coba ping ke 202.91.8.*** dan 202.91.*.*** , bila berhasil insyaAlloh ping ke mBah Google juga mau, he he…. Alhamdulillah……:) lalu dilanjutkan dengan konfigurasi untu NAT(Network Address Translation). Hal ini bertujuan; agar ip komputer client yang dihubungkan ke router FreeBSD bisa di kenali di Internet, jadi client bisa browsing dech…
file konfigurasinya terletak pada /etc/pf.conf
###################################################################
ext_if=”dc0″ # replace with actual external interface name i.e., dc0
int_if=”dc1″ # replace with actual internal interface name i.e., dc1
internal_net=”192.168.1.0/24″
external_addr=”202.91.11.226″
nat on $ext_if from $internal_net to any -> ($ext_if)
#di bawah sendiri tambahkan
pass in all
pass out all
###################################################################
setelah selesei konfigurasi, baru restart konfigurasi
moklet_psg#pfctl -F all -f /etc/pf.conf  atau reboot aja mesin FreeBSD-nya
lalu coba ping dari klien ke gateway jika berhasil, coba ping ke google.Jika berhasil, Alhamdulillah…Selesai juga setUp sederhana FreeBSD sebagai router, dan bisa dilanjutkan utk setUp selanjutnya. :)

dhcp server pada FreeBSD

ini juga....migrasi catatan jaman SMA dari http://maz-zoga.net84.net

******************************************************************    
#
#DHCP Server pada FreeBSD
#
******************************************************************
Hehe… :) jadi, setelah selesai buat mesin router FreeBSD aku lanjutin aja untuk mencoba - coba SetUp DHCP Server pada FreeBSD. Jadikan enak, tiap client tidak perlu susah-susah masukin alamat ip :)
DHCP merupakan protokol yang digunakan oleh komputer-komputer dalam sebuah jaringan untuk menentukan parameter seperti default gateway, subnet mask,  dan IP address, DNS dari DHCP server. Fungsi umum DHCP server adalah untuk mempermudah pengalokasian IP address (selanjutnya disebut IP) dan juga pengaturan IP yang sangat dinamis untuk membantu memudahkan user agar tidak perlu mensetting IP ketika ada penambahan user baru atau setelah format ulang sebuah PC.

Informasi lengkap mengenai DHCP silahkan baca dihttp://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol#Introduction.
Pertama cek dulu dhcp-servernya, sudah di install apa belum,
moklet_psg#pkg_info
jika belum install dulu
moklet_psg#cd /usr/ports/net/isc-dhcp3-server/
moklet_psg#make install clean
tunggu sampek prosesnya selesai baru konfigurasi file-nya yang terletak di /usr/local/etc/dhcpd.conf
### dhcp server ####################################################
####################################################################
ddns-update-style ad-hoc;
shared-network LOCAL-NET-dc1 {
        option domain-name “latihan.net”;
        option domain-name-servers 202.91.8.2, 202.91.8.3;
        subnet 192.168.1.0 netmask 255.255.255.0 {
                option routers 192.168.1.1;
                range 192.168.1.2 192.168.1.10;
        }
}
####################################################################
setelah selesai konfigurasi, jalankan daemon dhcp
moklet_psg#/usr/local/sbin/dhcpd -q dc1
atau simpan di /etc/rc.local   (utk menjalankn file secara otomatis setiap mesin pertamakali dihidupkan)
Selesai sudah proses menginstall dan menjalankan DHCP server. Untuk feature-feature lain silakan bereksprimen sendiri.
Sekarang kita coba DHCP server baru dengan mensetting obtain IP adress automatically pada PC windows atau menjalankan dhcpclient pada PC freebsd. Perhatikan aktivitas DHCP server lease tersebut dengan cara:
moklet_psg#tail -f  /var/db/dhcpd.leases


dns server pada FreeBSD

ini juga....migrasi catatan jaman SMA dari http://maz-zoga.net84.net

******************************************************************    
#
#DNS Server pada FreeBSD
#
******************************************************************
DNS (Domain Name System) adalah server yang bertugas memetakan hostname ke IP dan juga sebaliknya dari IP ke hostname. Secara default pada FreeBSD telah terinstall DNS server BIND9 (Berkeley Internet Name Domain).
sebelumnya cek dulu /etc/rc.conf –> named_enable=”YES”
konfigurasi file named.conf pada /etc/namedb/named.conf
 (tambahkan zona )
### dns server #####################################################
####################################################################
zone “latihan.net” {
        type master;
        file “master/latihan.net”;
};
zone “11.91.202.in-addr.arpa” {
        type master;
        file “master/202.91.11.226″;
};
——————————————————————–
cd /etc/namedb/
setelah konfigurasi named.conf, bangkitkan file localhost.rev
moklet_psg#sh make-localhost
lalu buat file latihan.net dan 202.91.11.226 pada /etc/namedb/master/
isi file latihan.net :
——————————————————————–
TTL            3600
@               IN      SOA             latihan.net. root.latihan.net. (
                                        20080805        ;serial
                                        3600            ;refresh
                                        900             ;retry
                                        3600000         ;expire
                                        3600    )       ;minimum
                NS      latihan.net.
                A       202.91.11.226
———————————————————————
isi file 202.91.11.226
———————————————————————
$TTL            3600
@               IN      SOA             latihan.net. root.latihan.net. (
                                        20080805        ;serial
                                        3600            ;refresh
                                        900             ;retry
                                        3600000         ;expire
                                        3600    )       ;minimum
                NS      latihan.net.
226             PTR     latihan.net.
——————————————————————–
setelah selesai setting bangkitkan rndc.conf
moklet_psg#rndc-confgen > rndc.conf
lalu setting pada /etc/resolv.conf
——————————————————————–
#nameserver 202.91.8.2
#nameserver 202.91.8.3
nameserver 127.0.0.1
———————————————————————
Jalankan !!
moklet_psg# /etc/rc.d/named start
Strating named
atau
moklet_psg#named
tes dg
moklet_psg# nslookup
> latihan.net
akan terlihat:
Server:         127.0.0.1
Address:        127.0.0.1#53
Name:   latihan.net
Address: 202.91.11.226
> 202.91.11.226
akan terlihat :
Server:         127.0.0.1
Address:        127.0.0.1#53
226.11.91.202.in-addr.arpa      name = latihan.net.
######################################################################
Alhamdulilah……, selesai juga DNS Servernya.

pf.conf dan transparent proxy dengan squid pada FreeBSD

ini juga....migrasi catatan jaman SMA dari http://maz-zoga.net84.net

******************************************************************    
#
#pf.conf dan Transparent Proxy dengan Squid pada FreeBSD
#
******************************************************************
trus aku coba untuk setting squid untuk Transparent proxy. Na ini ni yang bkin aku pusiiiiiiiing buaanget. Butuh waktu lama….., aku untuk setUp yg satu ini, ya maklum lah….baru belajar… Na memang begini kalee…  manis pahit-nya membaca dan mencoba yg di temenin Mbah Google..? :) Tapi setelah berHasil eeh ada kepuasan tersendiri di Hati.
Eeh aq kok sedikit nglantur yoW … he he he…..:) OK ku lanjutin dokumentasiku….
cek squid dg
moklet_psg#pkg_info
bila sudah tinggal konfigurasi, bila blm install dulu.
moklet_psg#cd /usr/ports/www/squid
moklet_psg#make install clean
buat direktori cache pada /usr/local/squid/
buat file access.log pada /usr/local/squid/logs/
buat file cache.log pada /usr/local/squid/logs/
buat file mime.conf pada /usr/local/squid/logs/
buat file store.log pada /usr/local/squid/logs/
Rubah kepemilikan directory
/usr/local/etc/squid#chown -R squid:squid /usr/local/squid/log
/usr/local/etc/squid#chown -R squid:squid /usr/local/squid/cache
lakukan konfigurasi pada
/usr/local/etc/squid/squid.conf
#####################################################################
### proxy ###
/usr/local/etc/squid/squid.conf
# NETWORK OPTIONS
# —————
http_port 3128
icp_port 3130
# OPTIONS WHICH AFFECT THE NEIGHBOR SELECTION ALGORITHM
# ——————————————————
mcast_icp_query_timeout 10
dead_peer_timeout 10 seconds
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY
# OPTIONS WHICH AFFECT THE CACHE SIZE
# ————————————
cache_mem 32 MB
cache_swap_low 90
cache_swap_high 95
maximum_object_size 4096 KB
maximum_object_size_in_memory 8 KB
ipcache_size 1024
ipcache_low 90
ipcache_high 95
fqdncache_size 1024
cache_replacement_policy lru
memory_replacement_policy lru
# LOGFILE PATHNAMES AND CACHE DIRECTORIES
# —————————————-
cache_dir ufs /usr/local/squid/cache 100 16 256
access_log /usr/local/squid/logs/access.log squid
cache_log /usr/local/squid/logs/cache.log
cache_store_log /usr/local/squid/logs/store.log
mime_table /usr/local/etc/squid/mime.conf
# OPTIONS FOR EXTERNAL SUPPORT PROGRAMS
# ————————————–
unlinkd_program /usr/local/libexec/squid/unlinkd
pinger_program /usr/local/libexec/squid/pinger
auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
auth_param basic casesensitive off
# OPTIONS FOR TUNING THE CACHE
# —————————–
#Suggested default:
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern .               0       20%     4320
# ACCESS CONTROLS
# —————-
#Recommended minimum configuration:
acl all src 0.0.0.0/0.0.0.0
acl localmachine src 192.168.1.0/24
acl publicip src 202.91.11.226
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443 563
acl Safe_ports port 80          # http
acl Safe_ports port 21          # ftp
acl Safe_ports port 443 563     # https, snews
acl Safe_ports port 70          # gopher
acl Safe_ports port 210         # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280         # http-mgmt
acl Safe_ports port 488         # gss-http
acl Safe_ports port 591         # filemaker
acl Safe_ports port 777         # multiling http
acl CONNECT method CONNECT
# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access deny manager
# Deny requests to unknown ports
http_access deny !Safe_ports
# Deny CONNECT to other than SSL ports
http_access deny CONNECT !SSL_ports
# be allowed
acl our_networks src 192.168.1.0/24
http_access allow our_networks
# And finally deny all other access to this proxy
http_access deny all
# and finally allow by default
http_reply_access allow all
#Allow ICP queries from everyone
icp_access allow all
# ADMINISTRATIVE PARAMETERS
# ————————–
cache_mgr stj_yog@yahoo.co.id
cache_effective_user squid
# HTTPD-ACCELERATOR OPTIONS
# ————————–
 httpd_accel_host virtual
 httpd_accel_port 80
 httpd_accel_with_proxy on
 httpd_accel_uses_host_header on
#Default:
# httpd_accel_no_pmtu_disc on
# MISCELLANEOUS
# ————–
logfile_rotate 10
snmp_port 3401
# DELAY POOL PARAMETERS (all require DELAY_POOLS compilation option)
# ——————————————————————-
coredump_dir /usr/local/squid/cache
___________________________ End ______________________________________
#######################################################################
Untuk konfigurasi pf.conf (untuk meredirect client), diletakkan di bawah nat
——————————————————————-
rdr on $int_if proto {tcp, udp} from any to any port www -> 202.91.11.226 \
port 3128
——————————————————————-
start squid #/usr/local/sbin/squid –DF
atau masukan /usr/local/sbin/squid –DF ke rc.local agar squid berjalan secara otomatis ketika server booting
menjalankan squid pertama kali
buat swap squid dengan mengetikan
#/usr/local/sbin/squid –z
menjalankan squid
#/usr/local/sbin/squid –DFY
liat : tail -f /usr/local/squid/access.log
Hanya yang Maha mengetahui segalanya-lah yang maha sempurna.Kiranya dokumentasi saya ini ada kesalahan mohon ma’af,Saya manusia biasa yang hanya mampu berusaha, segalanya hanya Alloh yang menentukan.Terimakasih buat semua yang telah membantu saya……

contoh isi file konfigurasi pf.conf pada FreeBSD

ini juga....migrasi catatan jaman SMA dari http://maz-zoga.net84.net

******************************************************************    
#
#Contoh isi file Konfigurasi pf.conf pada FreeBSD
#
******************************************************************
nah ini ada contoh isi file konfigrasi pf.conf yag pernah aku coba ni
moga ada manfaatya, keterangan lebih lanjut :
http://indofreebsd.or.id/
http://www.freebsd.org/
###################################################################
## == deklarasi interface ==
ext_if=”dc0″
int_if=”fxp0″
amikom =”{202.91.9.7, 202.91.9.8}”
table { 202.158.66.190, 203.190.241.41, 203.190.241.43, \
                   203.190.241.166, 202.158.66.20, 202.158.66.86, \
                   202.190.241.94 }
#block in on fxp0 from { } to any
#pass in on fxp0 from { } to any
## === Normalisasi===
#scrub in all
##== NAT ==
nat on $ext_if from 192.168.10.0/24 to any -> 202.91.11.228
##== transparent ===proxy ==
#rdr on $int_if proto {tcp,udp} from any to any port www -> $int_if port 3128
#rdr on $int_if proto tcp from any to any port ssh -> 202.91.8.245 port 22
##=== membolehkan akses====
pass in all
pass out all
##== Blocking situs===
block in on $int_if proto tcp from any to $int_if port ftp
block in on $int_if proto {tcp, udp}  from 192.168.10.0/24 to
block in on $int_if proto {tcp, udp, icmp} from 192.168.10.0/24 to $amikom
######################################################################

lupa password root pada freebsd

ini juga....migrasi catatan jaman SMA dari http://maz-zoga.net84.net

he he….. usil dikit ga pa pa yach..?
jadi gini ceritanya … waktu aku psg, aku pengin blajar proxy pada FreeBSD, tapi komputer yang buat aku sdh aku install fedora.Na….yang di install FreeBSD punya temen PSG aku dari skul laen. Aku ga tau passwordnya :( . Trus guwe mikir gmn caranya gua bisa masuk ke system-nya ??? setelah pikir panjang, gua baru inget kalo punya kenalan yang handal he he siapa dia??
Dia adalah Mbah Google… he he :)
Siiiiiiip lah, trus waktu aku coba ternyata sukses. Alhamdulillah…..
Pertama waktu boot tekan spacebar. Setelah itu masuk sebagai single user caranya berbeda-beda.Klo dari referensi yang aku baca dg mengetikkan boot -s, tapi klo yang gue praktik-kan dengan menekan 4.
Setelah itu ada Enter full pathname of shell or RETURN for /bin/sh –> tekan enter saja.
bisa masuk tanpa password bukan ?
tapi perlu di ingat anda belum bisa melakukan apa apa pada # shell ini
karena file system yang di mount adalah read only .
gimana supaya kita bisa mengakses file system seperti biasa dan bisa merubah password ?
caranya adalah mount filesystem secara keseluruhan, yang perlu di lakukan adalah
# mount -t ufs -a
nah setelah itu barulah kita bisa me reset password root tesebut.
#passwd
masukkan password baru, Retype new password:
setelah itu reboot dan coba login sbg root dan coba password baru anda.
Insya Alloh manjur he he…..
makasih buat petunjuknya ya….mas ogeb
Indonesian FreeBsd Community