Minggu, 06 Maret 2011

Konfigurasi DNS




Konfigurasi DNS

  1. Edit  file /etc/bind/named.conf.local
Unutk editor bias menggunakan vi atau nano.

Cd  /etc/bind/
Cat named.conf  >> named.conf.local

Nano named.conf.local. Lihat pada configurasi file ini pada halaman belakang


  1. cp db.local xxx.ac.id
edit sehingga nampak sebagai berikut:
            ;
; BIND data file for local loopback interface
;
$TTL     604800
@ IN      SOA     ns.kampusb.ac.id. root.kampusb.ac.id. (
               2008110401       ; Serial
                  604800        ; Refresh
                   86400        ; Retry
                 2419200        ; Expire
                  604800 )      ; Negative Cache TTL
;
@ IN      NS      kampusb.ac.id.
@ IN      A       192.168.30.58
www      IN      CNAME   @
@ IN      MX      10 @


  1. cp db.127 192.168.30.in-addr.arpa


  1. Buat file baru dengan nama file sesuai hostname anda contoh xxx.ac.id
nano /etc/bind/xxx.ac.id, dan ketik:

;
; BIND data file for local loopback interface
;
$TTL   604800
@        IN        SOA    ns.kampusb.ac.id. root.kampusb.ac.id. (
                              2008110401          ; Serial
                                     604800                       ; Refresh
                                      86400                        ; Retry
                                    2419200                      ; Expire
                                     604800 )         ; Negative Cache TTL
;
@        IN        NS       kampusb.ac.id.
@        IN        A         192.168.30.58
www   IN        CNAME         @
@        IN        MX      10 @




  1. Restart dns server
/etc/init.d/bind9 restart

  1. Test dns server
Nslookup
> server xxx.ac.id
   result 
> yahoo.com
   result

atau dig xxx.ac.id

Sabtu, 05 Maret 2011

Cara buat FIREWALL DI LINUX

1.install iptables
2.configure script bin/sh firewall
3.ruleset iptables

work now heheh

1. install iptables pada server ubuntu anda

Commandnya: apt-get install iptables

setelah proses selesai Done

kita lanjut ke tahap kedua ...

2.configure script bin/sh firewall

disini saya membuat sebuah script !/bin/sh dimana nantinya akan berfungsi sebagai pengontrol iptables (menghidup matikan firewall)

pertama-tama

cd /sbin

nano firewall <== nama file script yg saya buat

masukan configure script ini

=============================================================================================

#!/bin/sh
#
# Letjen Seting Iptables for ubuntu OS
# http://malanghack.net, http://sekuritionline.net
# and was Copyrighted 2007 by the Letjen

IPTABLES_SAVE="/etc/default/iptables-rules"
SAVE_RESTORE_OPTIONS="-c"
SAVE_ON_STOP="yes"

checkrules() {
if [ ! -f ${IPTABLES_SAVE} ]
then
echo "Tidak Bisa start iptables. Silahkan Buat Rule Seting Iptables"
echo ""/etc/init.d/iptables save""
return 1
fi
}

save() {
echo "Saving iptables state "
/sbin/iptables-save ${SAVE_RESTORE_OPTIONS} > ${IPTABLES_SAVE}
}

start(){
checkrules || return 1
echo "Loading and starting firewall "
echo -n "Firewall Start Protect Your Server"
start-stop-daemon --start --quiet --exec /sbin/iptables-restore -- ${SAVE_RESTORE_OPTIONS} < ${IPTABLES_SAVE}
}

case "$1" in
save)
save
echo "."
;;

start)
start
echo "."
;;
stop)
if [ "${SAVE_ON_STOP}" = "yes" ]; then
save || exit 1
fi
echo -n "Peringatan firewall Berhenti"
for a in `cat /proc/net/ip_tables_names`; do
/sbin/iptables -F -t $a
/sbin/iptables -X -t $a

if [ $a == nat ]; then
/sbin/iptables -t nat -P PREROUTING ACCEPT
/sbin/iptables -t nat -P POSTROUTING ACCEPT
/sbin/iptables -t nat -P OUTPUT ACCEPT
elif [ $a == mangle ]; then
/sbin/iptables -t mangle -P PREROUTING ACCEPT
/sbin/iptables -t mangle -P INPUT ACCEPT
/sbin/iptables -t mangle -P FORWARD ACCEPT
/sbin/iptables -t mangle -P OUTPUT ACCEPT
/sbin/iptables -t mangle -P POSTROUTING ACCEPT
elif [ $a == filter ]; then
/sbin/iptables -t filter -P INPUT ACCEPT
/sbin/iptables -t filter -P FORWARD ACCEPT
/sbin/iptables -t filter -P OUTPUT ACCEPT
fi
done
start-stop-daemon --stop --quiet --pidfile /var/run/iptables.pid --exec /sbin/iptables
echo "."
;;

restart)
echo -n "Flushing firewall"
for a in `cat /proc/net/ip_tables_names`; do
/sbin/iptables -F -t $a
/sbin/iptables -X -t $a
done;
start
echo "."
;;
*)
echo "Gunakan: firewall {start|stop|restart|save}" >&2
exit 1
;;
esac

exit 0

=============================================================================================

Perhatikan (IPTABLES_SAVE="/etc/default/iptables-rules" ini merupakan script default yg akan menyimpan
rule iptables yg nantinya kita buat

tahap kedua udah lese now go to last sesion

3.Ruleset iptables

a.cara membuat rule iptables kita

anda dapat menggunakan perintah : sudo iptables -A INPUT ...

setelah memasukan rule iptables jangan lupa ketik perintah : firewall save (bertujuan untuk menyimpan rule iptables)

b.Cara kedua yg bisa kita pakai juga ialah dengan mengedit iptables-rules yg terdapat pada directory /etc/default/

contoh rule iptables ketik : nano /etc/default/
=-==============================================================================================
# Generated by iptables-save v1.3.3 on Fri Jul 6 15:33:21 2007
*mangle
REROUTING ACCEPT [774:59782]
:INPUT ACCEPT [774:59782]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [477:81340]
OSTROUTING ACCEPT [477:81340]
COMMIT
# Completed on Fri Jul 6 15:33:21 2007
# Generated by iptables-save v1.3.3 on Fri Jul 6 15:33:21 2007
*filter
:INPUT ACCEPT [596:44876]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [477:81340]
[178:14906] -A INPUT -p icmp -m icmp --icmp-type 8 -j DROP
[0:0] -A INPUT -p udp -j DROP
[0:0] -A INPUT -p tcp -m tcp --dport 21 -j ACCEPT
[0:0] -A INPUT -p tcp -m tcp --dport 25 -j REJECT --reject-with icmp-port-unreachable
[0:0] -A INPUT -p tcp -m tcp --dport 53 -j ACCEPT
[0:0] -A INPUT -p tcp -m tcp --dport 110 -j REJECT --reject-with icmp-port-unreachable
[0:0] -A INPUT -p tcp -m tcp --dport 113 -j REJECT --reject-with icmp-port-unreachable
[0:0] -A INPUT -p tcp -m tcp --dport 465 -j REJECT --reject-with icmp-port-unreachable
[0:0] -A INPUT -p tcp -m tcp --dport 993 -j REJECT --reject-with icmp-port-unreachable
[0:0] -A INPUT -p tcp -m tcp --dport 995 -j REJECT --reject-with icmp-port-unreachable
[0:0] -A INPUT -p tcp -m tcp --dport 143 -j REJECT --reject-with icmp-port-unreachable
[0:0] -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
[0:0] -A INPUT -p tcp -m tcp --dport 3306 -j REJECT --reject-with icmp-port-unreachable
[0:0] -A INPUT -p tcp -m tcp --dport 8080 -j REJECT --reject-with icmp-port-unreachable
COMMIT
# Completed on Fri Jul 6 15:33:21 2007
# Generated by iptables-save v1.3.3 on Fri Jul 6 15:33:21 2007
*nat
REROUTING ACCEPT [184:15226]
OSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
COMMIT
# Completed on Fri Jul 6 15:33:21 2007

=================================================================================================

Nah kita bisa mengedit dan menambahkan rule yg kita mau di sana

finis move : firewal start

Loading and starting firewall
Firewall Start Protect Your Server.

Membuat Proxy Server Ubuntu 10.10

Konfigurasi sebagai Proxy Server (Caching Proxy, Transparent Proxy, Web Filter)

1. install squid
#apt-get install squid

2. edit file "squid.conf"
#nano /etc/squid/squid.conf

bagian-bagian yg harus diedit dan ditambah pada file "squid.conf" agar squid berfungsi sebagai Caching Proxy, Transparent Proxy, dan Web Filter...

http_port 3128
menjadi:
http_port 3128 transparent

# cache_effective_user proxy
menjadi:
cache_effective_user proxy (yg kita hilangkan hanya tanda '#')

# cache_effective_group proxy
menjadi:
cache_effective_group proxy (pada beberapa versi squid, baris ini tidak ada. jadi kita mesti buat manual)

visible_hostname admin@smkyadika-llg.sch.id (tambahkan baris visible_hostname alamat situs web)

# cache_mem 8 MB
menjadi:
cache_mem 20 MB (besar memori yg di alokasikan untuk squid server)

#cache_mgr webmaster
menjadi:
cache_mgr admin@smkyadika-llg.sch.id

# cache_dir ufs /var/spool/squid 100 16 256
menjadi:
cache_dir ufs /cache 2000 16 256 (2000/2GB = besar alokasi folder cache, 16 = jumlah subdirektori tingkat 1, 256 = jumlah subdirektori tingkat 2)


tambahkan alamat network yg diperbolehkan untuk mengakses proxy server. edit squid.conf pada bagian recommended minimum configuration: hingga menjadi seperti dibawah.

#Recommended minimum configuration:
acl all src 0.0.0.0/0.0.0.0.
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 lan src 192.168.50.0/24 (baris ini adalah alamat network yg diperbolehkan untuk mengakses proxy server)


tambahkan hak akses alamat network dan hak akses situs yg akan di filter/block. edit squid.conf pada bagian http_access allow localhost hingga menjadi seperti dibawah.

acl situsx dstdomain "/etc/squid/situsx" (situsx adalah nama file yg nantinya berisi situs2 yg terblokir)
http_access deny situsx (melarang hak akses atas file situsx)
http_access allow localhost
http_access allow lan (memperbolehkan hak akses atas alamat network)
#and finally deny all other access to this proxy
http_access deny all


3. tambahkan perintah iptables pada file rc.local untuk konfigurasi transparent proxy agar semua client dipaksa masuk ke port 3128.
#nano /etc/rc.local

iptables -A PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-port 3128
(perintah iptables tidak wajib ditulis di rc.local, hanya saja saat kompi direstart, maka perintah iptables tersebut akan hilang.)


4. kemudian buat file situsx, file ini akan kita isi alamat/situs yg akan kita block.
#nano /etc/squid/situsx

www.facebook.com
www.youtube.com
www.xxx.com
www.apasajaoke.com


5. setelah semua selesai, simpan/save hasil konfigurasinya. sekarang kita buat folder cache untuk proxy tadi.

#mkdir /cache
#chown proxy.proxy /cache
#squid -z


6. sekarang coba jalankan squid, dan lihat hasil konfigurasi iptables kita


#/etc/init.d/squid start

#iptables -L -t nat

Cara Setting PC Router di Ubuntu

Dalam hal ini, server kita memiliki 2 NIC
 
Langkah pertama , kita cek NIC server kita.
# mii-tool
Kemudian setting network interfacenya
# nano /etc/network/interfaces

masukan konfigurasi sbg berikut:
auto eth0
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1
network 192.168.1.0
broadcast 192.168.1.255
auto eth1
iface eth1 inet static
address 192.168.50.1
netmask 255.255.255.0
network 192.168.50.0
broadcast 192.168.50.255

konfigurasi file resolv.conf (DNS Server) pada direktori /etc/
# nano /etc/resolv.conf
lakukan konfigurasi sbg berikut:
nameserver 202.134.0.155
nameserver 202.134.1.10
(sesuaikan dg DNS kita)

 konfigurasi IP di pc client sebagai berikut :
IP Address 192.168.50.2
Subnet Mask 255.255.255.0
Default Gateway 192.168.50.1 ( IP Server /eth1)
Preffered DNS Server 202.134.0.155
Alternate DNS Server 202.134.1.10
 (konfigurasi ini dilakukan di PC  CLIENT)

konfigurasi file sysctl.conf
# nano /etc/sysctl.conf
Cari kalimat dibawah ini dan hilangkan tanda #
# net.ipv4.ip_forward=1 sehingga menjadi
net.ipv4.ip_forward=1
Lalu simpan.

aktifkan ip forwardernya
sysctl -w net.ipv4.ip_forward=1
Lalu cek ip forwardermya
# cat /proc/sys/net/ipv4/ip_forward
Jika sudah aktif, maka akan muncul angka 1


cek apakah routing berjalan atau belum.  
# iptables –t nat –n –L 

PERHATIAN !
Besar kecil huruf berpengaruh. Kemudian konfigurasi file rc.local
# nano /etc/rc.local
Tambahkan konfigurasi routing  exit = 0:
iptables –t nat –A POSTROUTING –o eth0 –j MASQUERADE
iptables –t nat –A POSTROUTING –s 192.168.50.0/24 –j MASQUERADE
kemudian simpan.
lalu simpan konfigurasi IP Tables/Perintah Routing
# iptables-save > /etc/iptables.conf
Update service jaringan yang baru dikonfigurasi, dan Selesai…
# /etc/init.d/networking restart