Proxy gateway CentOS 6


I. Skenario:
Internet Router — eth0:192.168.0.11:cumi.bachem.local:eth1:192.168.10.1 — client

II. Setting Statik IP Address,DNS, etc
# system-config-network-tui

or

-Via CLI, setting ip address eth0
# cd /etc/sysconfig/network-scripts/
# vi ifcfg-eth0

 

-Setting ip address eth1
# cd /etc/sysconfig/network-scripts/
# vi ifcfg-eth1

 
-Setting DNS:
# vi /etc/resolv.conf

 
-Setting Hostname:
# vi /etc/sysconfig/network

 
-Setting /etc/hosts
# vi /etc/hosts

 
III. Update Server
# yum –y update

IV. Setting NAT/Sebagai Router/Gateway
-Enable IP forwarding
# sysctl -w net.ipv4.ip_forward=1

-To enable it in system startup, edit the file /etc/sysctl.conf
# vi /etc/sysctl.conf
and set
net.ipv4.ip_forward = 1

-Enables packet forwarding by kernel
# echo 1 > /proc/sys/net/ipv4/ip_forward
OR edit /proc/sys/net/ipv4/ip_forward , change 0 to 1 then save

-Setting iptables untuk NAT
# iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
# iptables -I INPUT -i eth1 -p tcp --dport 3128 -j ACCEPT
# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

# service iptables save
# service iptables restart

III. Install & Setting Squid
-Install Paket Squid 3.1 from default CentOS 6 repo
# yum -y install squid

-Konfigurasi Squid
# cp /etc/squid/squid.conf /etc/squid/squid.conf.asli
# vi /etc/squid/squid.conf