Wednesday, December 10, 2014

Blok youtube dengan Cisco router

Blok traffic youtube dengan cisco
router harus support fasilitas NBAR

ada 2 cara blok yaitu :

1. dengan menggunakan HTTP

buat class

R1(config)#class-map match-any BLOCKED
R1(config-cmap)#match protocol http host "*youtube.com"
R1(config-cmap)#exit
 
buat policy

R1(config)#policy-map DROP 
R1(config-pmap)#class BLOCKED
R1(config-pmap-c)#drop
R1(config-pmap-c)#exit 

aplikasikan ke interface yg akan di blok
R1(config)#interface fastEthernet 0/1 
R1(config)#ip nbar protocol-discovery 
R1(config-if)#service-policy output DROP
 
 
melihat konfigurasi
 
R1#show policy-map interface fastEthernet 0/1
 FastEthernet0/1 

  Service-policy output: DROP

    Class-map: BLOCKED (match-any)
      1 packets, 500 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: protocol http host "*youtube.com*"
        1 packets, 500 bytes
        5 minute rate 0 bps
      drop

    Class-map: class-default (match-any)
      6101 packets, 340841 bytes
      5 minute offered rate 10000 bps, drop rate 0 bps
      Match: any 
 
 
2. Dengan fasilitas cisco
 
  perbedaan pada difinisi class
 
  R1(config)#class-map match-any BLOCKED
  R1(config-cmap)#match protocol youtube
  R1(config-cmap)#exit
 
 
contoh yang lainnya :
 
 
Example to match based on Host and URL
This example will match the page "cisco.com/go/nbar", as well as www.cisco.com/go/nbar and other variants.
class-map match-all
match protocol http host "*cisco.com"
match protocol http url "/go/nbar" 
 
 
Example to match based on host or URL
This example is similar to the previous one except that it matches on either the host name or the URL. Note the "match-any" statement:
class-map match-any
match protocol http host "www.cisco.com"
match protocol http url "*.exe"
Example to block Facebook traffic
This example will block HTTP traffic to the social network site Facebook.
class-map match-all facebook
match protocol http host "*facebook.com"
!
policy-map nofacebook
class facebook
drop
!
interface FastEthernet4
service-policy output nofacebook
 

BLOK YOUTUBE DAN FACEBOOK DENGAN IPTABLES

UNTUK memblok ada dua cara yaitu:

1.  blok ip address

FB - iptables -A OUTPUT -p tcp --destination-port 80,443 -d 31.13.64.0/15 -j REJECT

Twittier -  iptables -A OUTPUT -p tcp --destination-port 80,443 -d 199.59.148.0/22 -j REJECT

Youtube - iptables -A OUTPUT -p tcp --destination-port 80,443 -d 74.125.0.0/16 -j REJECT


2. langsung ketik alamat web

#iptables -A OUTPUT -d www.facebook.com -j REJECT

Iptabes Fedora 19

mengaktifkan iptables :

systemctl enable iptables.service
systemctl enable ip6tables.service
systemctl start iptables.service
systemctl start ip6tables.service

me-non-aktifkan IPTABLES :

[root@fedora ~]# systemctl stop iptables.service
[root@fedora ~]# systemctl stop ip6tables.service
[root@fedora ~]# systemctl disable iptables.service
rm '/etc/systemd/system/basic.target.wants/iptables.service'
[root@fedora ~]# systemctl disable ip6tables.service
rm '/etc/systemd/system/basic.target.wants/ip6tables.service'

Menyimpan Konfigurasi IPTABLES

[root@fedora ~]# iptables-save > /etc/sysconfig/iptables

Restore konfigurasi IPTABLES
[root@fedora ~]# iptables-restore > /etc/sysconfig/iptables.old

Mereset IPtables :

iptables -F

contoh

iptables -F INPUT