Saturday, January 30, 2016

Blokir Situs Berbasis Contain Menggunakan IPTABLES Linux

Bagi admin di kantor yang dipusingkan oleh user pengguna internet karena susah mengkontrol sehingga menghancurkan bandwith internet sampai lemooot habis, biasanya kita membagi bandwith dan kontrol akses internet menggunakan proxy, yang dilinux bisa menggunakan squid, tapi bisa untuk user yang nyeleneh dan tahu triknya masih bisa bikin admin kecolongan.

Nah langsung saja saya coba kasih trik yang mudah-2an berguna, saya sudah mencoba menggunakan tips ini di 2 jaringan berbeda, satu menggunakan pc router linux slackware 14, dan satu lagi menggunakan pc router linux RHEL5 update 7. 

Konfigurasi Link Internet / infrastruktur :

Modem Indihome --- > (eth0) --> PC ROUTER RHEL5/Slackware14 --> (eth1 ) ---> PC USER

Bikin file blokir

vi blokir

masukkan scrip dibawah ini :

### IP USER YANG DIBOLEHKAN AKSES FULL ( BOS, ADMIN DAN SEKDIR )

iptables -A FORWARD -s 192.168.1.71/32 -d 0/0 -j ACCEPT   ### BOS
iptables -A FORWARD -s 192.168.1.230/32 -d 0/0 -j ACCEPT ### SEKDIR
iptables -A FORWARD -s 192.168.1.50/32 -d 0/0 -j ACCEPT   ### NETWORK ADMIN


### SELAIN BOS, SEKDIR DAN ADMIN TIDAK BOLEH AKSES SITUS TERTENTU DAN MENDOWNLOAD FILE TERTENTU ( SUKA SUKA IT NYA )

iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string tube -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string xvideos -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string xnxx -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string facebook -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string twitter -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string googlevideo.com -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string downloads.ziddu.com -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string internetdownloadmanager.com -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string instagram -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string play.google -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string plus.google -j DROP

### FILE SERVER YANG TIDAK BOLEH DI AKSES

iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string torrent -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string rapidshare -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string hotfile -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string depositfiles -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string mediafire -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string 4shared -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string downloads.ziddu.com -j DROP


### FILE YANG TIDAK BOLEH DI DOWNLOAD

iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string '.mov' -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string '.wmv' -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string '.asf' -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string '.exe' -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string '.mp4' -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string '.flv' -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string '.iso' -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string '.mpeg' -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string '.mpg' -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string '.3gp' -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string '.avi' -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string '.mkv' -j DROP
iptables -A FORWARD -s 0/0 -o eth0 -m string --algo kmp --string '.apk' -j DROP


Simpan scrip diatas menjadi file blokir 
kemudian beri akses full execute file blokir

chmod 777 blokir

jalankan scrip blokir

./blokir

Semoga bermanfaat

Thursday, January 28, 2016

Install Oracle 12 di Linux RHL7 / RedHat 7

Kebetulan saya menggunakan Server Hp Proliant ML350 Generasi 9 dan diinstall menggunakan RHL7 64bit.

Yang saya ketik dibawah ini adalah history dari server setelah berhasil install.

Pertama pastikan server linux kita terhubung langsung ke internet, karena untuk install oracle RHL7 packet pendukungnya tidak terdapat di cd. Kemudian kita harus login sebagai root langsung dari xwindows atau bisa menggunakan su - root.

Paket-paket pendukung kebetulan saya tidak mempunyai account di RedHat.com, tapi jangan kuatir ternyata oracle menyediakan server public yg bisa membantu kita mendapatkan paket secara langsung.


  • ketik perintah ini sebelum nya:


cd /etc/yum.repos.d/


  • kemudian kita download file repo public-yum:


wget http://public-yum.oracle.com/public-yum-ol7.repo
wget http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol7 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle


  • Setelah berhasil download restart server linux kita.


reboot


  • Setelah Server nyala login kembali sebagai root, kemudian seperti biasa setiap install oracle di redhat kita harus chek file hosts :


vi /etc/hosts

Pastikan isi file host nya:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.1 ml350g.localdomain ml350g


  • Kemudian siapkan cd oracle 12 linux  atau bisa Download Oracle 12linux ada 2 files


-linuxamd64_12102_database_1of2.zip
-linuxamd64_12102_database_2of2.zip


  • Kemudian extract:


unzip linuxamd64_12102_database_1of2.zip 
unzip linuxamd64_12102_database_2of2.zip 


  • Setelah itu edit file sysctl.conf :


vi /etc/sysctl.conf

## > isi paling bawah
-----------------------------------------------
### oracle install
fs.file-max = 6815744

kernel.sem = 250 32000 100 128

kernel.shmmni = 4096

kernel.shmall = 1073741824

kernel.shmmax = 4398046511104

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048576

fs.aio-max-nr = 1048576

net.ipv4.ip_local_port_range = 9000 65500
------------------------------------------------


  • Simpan kemudian jalankan perintah ini:


/sbin/sysctl -p


  • edit file limits.conf


vi /etc/security/limits.conf

isi di paling bawah:

## oracle setting
oracle   soft   nofile    1024
oracle   hard   nofile    65536
oracle   soft   nproc    2047
oracle   hard   nproc    16384
oracle   soft   stack    10240
oracle   hard   stack    32768


  • Kemudian install paket-paket oraclenya menggunakan perintah yum, pastikan server terhubung langsung ke internet :


yum install binutils -y
yum install compat-libstdc++-33 -y
yum install compat-libstdc++-33.i686 -y
yum install gcc -y
yum install gcc-c++ -y
yum install glibc -y
yum install glibc.i686 -y
yum install glibc-devel -y
yum install glibc-devel.i686 -y
yum install glibc -y
yum install ksh -y
yum install libgcc -y
yum install libgcc.i686 -y
yum install libstdc++ -y
yum install libstdc++.i686 -y
yum install libstdc++-devel -y
yum install libstdc++-devel.i686 -y
yum install libaio -y
yum install libaio.i686 -y
yum install libaio-devel -y
yum install libaio-devel.i686 -y
yum install libXext -y
yum install libXext.i686 -y
yum install libXtst -y
yum install libXtst.i686 -y
yum install libX11 -y
yum install libX11.i686 -y
yum install libXau -y
yum install libXau.i686 -y
yum install libxcb -y
yum install libxcb.i686 -y
yum install libXi -y
yum install libXi.i686 -y
yum install make -y
yum install sysstat -y
yum install unixODBC -y
yum install unixODBC-devel -y
yum install zlib-devel -y
yum install zlib-devel.i686 -y


  • Setelah paket selesai terinstall lanjutkan membuat user dan grup install oracle :


groupadd -g 54321 oinstall
groupadd -g 54322 dba
groupadd -g 54323 oper
useradd -u 54321 -g oinstall -G dba,oper oracle
passwd oracle


  • Kemudian edit file config atau pastikan firewall non aktif :


vi /etc/selinux/config

SELINUX=permissive


  • Atau jalankan langsung perintah :


setenforce Permissive
systemctl stop firewalld
systemctl disable firewalld


  • Selanjutnya kita siapkan lokasi penyimpanan database nya:


mkdir -p /home/u01/app/oracle/product/12.1.0.2/db_1
chown -R oracle:oinstall /home/u01
chmod -R 775 /home/u01


  • Kemudian ketik :


xhost +


  • Kemudian edit .bash_profilenya:


vi /home/oracle/.bash_profile

isi:

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs
# Oracle Settings

export TMP=/tmp
export TMPDIR=$TMP

export ORACLE_HOSTNAME=ml350g.localdomain
export ORACLE_UNQNAME=DATAORA
export ORACLE_BASE=/home/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.1.0.2/db_1
export ORACLE_SID=DATAORA

export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

if [ $USER = "oracle" ]; then
  if [ $SHELL = "/bin/ksh" ]; then
    ulimit -p 16384
    ulimit -n 65536
  else
    ulimit -u 16384 -n 65536
  fi
fi

PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH


  • Simpan filenya kemudian login sebagai oracle :


su - oracle


  • Selanjutnya kita mulai install oracle database R12 dengan file yg di extrak tadi berada di folder /home/oracle kemudian ketik :


$DISPLAY=:0.0; export DISPLAY
$cd database/
$./runInstaller


  • Install oracle database, container jangan ada cheklist kemudian lanjut saja install.



  • Setelah berhasil install oraclenya edit file oratab untuk memastikan oracle up pada saat server nyala:


vi /etc/oratab

DATAORA:/home/u01/app/oracle/product/12.1.0.2/db_1:Y


  • Simpan kemudian restart servernya, selamat mencoba dan semoga berhasil .



  • Jangan lupa mengaktifkan tnsclient nya ya :


su - oracle


lsnrctl start
emctl start dbconsole
isqlplusctl start


TAMBAHAN :

membuat script startup_oracle

vi startup_oracle

lsnrctl start
sqlplus "/ as sysdba" << EOF
startup
quit
EOF
emctl start dbconsole
isqlplusctl start


  • simpan, kemudian beri akses execute file startup_oracle


chmod 777 startup_oracle

coba di jalankan dengan menggunakan login sebagai oracle

su - oracle
./startup_oracle

==> Perintah yang saya tulis diatas sesuai dengan yang saya praktekkan dengan menggunakan server HP PROLIANT ML350 Gen 9 menggunakan OS RHL7 64bit, Semoga bermanfaat.