Monday, July 25, 2005

Router dengan LINUX

#############################################
Router dengan LINUX ( Fedora Core-2 )
#############################################


Note : Sebelum install mending buat netscafe dolo, idupin TV atau mp3 :P


1. Install LINUX melalui CDRoom/Ftp/DOS.
( saya gunakan Fedora Core-2 )

* Custom
* Automatic
* Remove all partition
* DHCP uncheck
* setting IP
> IP addres
gateway
DNS
* no firewell
* Development tools (check list)
install .....


2. setelah tahap install selesai, lalu isikan ip address untuk Routernya pada eth0 dan eth1.
Ok sekarang kita berasumsi mempunyai blok ip public dan local :

- untuk ip public :

Blok IP = 202.162.198.154 - 158 -----> range ip yg bisa di pakai.
Subnetmask = 255.255.255.248 -----> Netmask.
GateWay = 202.162.198.153

- Untuk Ip Local :

Blok Ip = 192.168.0.1 - 254
Subnetmask = 255.255.255.0

Sekarang kita Konfigurasi eth0 dan eth1 :

# vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=202.162.198.154
NETMASK=255.255.255.248
GATEWAY=202.162.198.153

# vi /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.1
NETMASK=255.255.255.0


# vi /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=RouterName

# /etc/init.d/network restart

# ifconfig


3. Untuk memforward paket pastikan :

# vi /etc/sysctl.conf

net.ipv4.ip_forward = 1

# sysctl -p /etc/sysctl.conf


4. OK sekarang kita install squid versi .rpm agar lebih cepat :P
dalam hal ini saya gunakan squid-2.5.STABLE4-2.i686.rpm :

# wget http://hostname/mirror/squid-2.5.STABLE4-2.i686.rpm

# rpm -ivh squid-2.5.STABLE4-2.i686.rpm

# squid -z

# vi /etc/squid/squid.conf


#Konfigurasi untuk ip dan port squid nya.
http_port 192.168.0.1:3128

#Konfigurasi untuk cache dir.
cache_dir diskd /var/spool/squid 512 16 256

#direktory log cache.
cache_access_log /var/log/squid/access.log
cache_log /var/log/squid/cache.log
cache_store_log none

#group dan user squid
cache_effective_user squid
cache_effective_group squid


# /etc/init.d/squid start

# ps ax|grep squid

#pastikan squid berjalan baik :
Squid -D
(squid) -D
diskd 255450 3578665 455678


# netstat -pln | grep squid

# tail -f /var/log/squid/cache.log

# ntsysv

#untuk mengaktivkan service squid :
(*) squid --> cek list


# vi /etc/wgetrc

#untuk Konfigurasi proxy :
http_proxy = http://192.168.0.1:3128/
use_proxy = on
waitretry = 10


5. Sekarang Kita Konfigurasi Iptables dan NAT untuk transparant Proxy :


# iptables -t nat -A PREROUTING -s 192.168.0.0/255.255.255.0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128

# iptables -t nat -A POSTROUTING -s 192.168.0.0/255.255.255.0 -j MASQUERADE

# /etc/init.d/iptables save

# /etc/init.d/iptables restart

# iptables -t nat -nL

# reboot