Google Search

Google
 

Monday, January 28, 2008

Ubuntu 7.10 + Bridge + Transparent Proxy (Squid) + Webmin

:) I'm happy that I have install my server and currently running for production. Here is the simple tutorial I want to share with u guys :

1. Install Ubuntu 7.10 (Gusty)
a. Download ubuntu iso from ftp://kambing.ui.edu/pub/ubuntu/releases/gutsy/ubuntu-7.10-server-i386.iso or download from the nearest mirror.

b. Burn the Image (*.iso) to the CD. (you can use Nero or others software to burn it).

c. Set your bios to boot from CDROM and put your Ubuntu Server's CD on the CDROM.

d. Boot it and follow the instruction.

Note : When installation, will be a question about server package you want to Install. In this case, I tick LAMP & SSH (for remote) option.

2. Install Bridge

We need to use 2 NIC (network card) to implement Bridge mode and below is my network scheme :

[Internet: 192.168.1.1] ---- [eth0:192.168.1.2 :eth1] ---- [SWITCH:]==[Office:192.168.1.10-192.168.1.254]

So what we need to do are :
a. Install required application / package

wilson@gateway:~$ sudo apt-get install iptables ebtables bridge-utils
[sudo] password for wilson: <== key-in your password

b. Setup eth0 & eth1 become bridge when start/restart

wilson@gateway:~$ sudo nano /etc/rc.local

add following to the rc.local before "exit 0"

brctl addbr br0
ifconfig eth0 0.0.0.0 promisc up
ifconfig eth1 0.0.0.0 promisc up
brctl addif br0 eth0
brctl addif br0 eth1
ip link set br0 up
ip addr add 192.168.1.2/24 brd + dev br0
route add default gw 192.168.1.1 dev br0

Description :
brctl addbr br0 <== interface for the bridge
ifconfig eth0 0.0.0.0 promisc up <== make eth0 become no Ip Address
ifconfig eth1 0.0.0.0 promisc up <== make eth1 become no IP Address
brctl addif br0 eth0 <== add eth0 to br0
brctl addif br0 eth1 <== add eth1 to br0
ip link set br0 up <== turn on br0
ip addr add 192.168.1.253/24 brd + dev br0 <== this required if you want to manage it remotely
route add default gw 192.168.1.1 dev br0 <== add default gateway


c. Make eth0 & eth1 become no Ip Address

wilson@gateway:~$ sudo nano /etc/network/interfaces

delete all of the content contain eth0 and eth1 to become :

auto lo
iface lo inet loopback

d. reboot and test the server

After reboot the machine, try to ping the br0 Ip address. If it's work's then Binggo :) your machine already configured become Bridge.

3. Install Squid

Squid is a proxy server application that can help you cache the www content, block content and authentication.

wilson@gateway:~$ sudo apt-get install squid

Now, you get your proxy server working. For more of squid configuration you can learn it from http://www.squid-cache.org, but in this tutorial I give some simple configuration for our proxy to become transparent.

Edit squid configuration files:

wilson@gateway:~$ sudo nano /etc/squid/squid.conf

Search, change and add the following configuration.

http_port 3128 transparent
acl lan src 192.168.1.0/24
http_access allow lan

Save it and restart the squid.

wilson@gateway:~$ sudo /etc/init.d/squid restart

4. Redirect http port to Proxy

Well, you have your proxy server (squid) running. But if you check it's log when your client do browsing, it's not using proxy. Why ???

It's because when your client browsing to a website, it's using port 80 and the proxy is 3128 by default. So we need to redirect port 80 to 3128. How ?

Note : in Ubuntu 7.10 you will find problem on ebtables cause there are some bugs on the Ubuntu ebtables, it's sound like miss link. So I make canocial link to solve the problem.

wilson@gateway:~$ sudo ln -s /etc/ethertypes /debian/ebtables/etc/ethertypes


wilson@gateway:~$ ebtables -t broute -A BROUTING -p IPv4 --ip-protocol 6 --ip-destination-port 80 -j redirect --redirect-target ACCEPT



wilson@gateway:~$
iptables -t nat -A PREROUTING -i br0 -p tcp --dport 80 -j REDIRECT --to-port 3128

Now, when you check on the logs files. You can see that it's working :)

How to check the log ???

wilson@gateway:~$ sudo tail -f /var/log/squid/access.log

5. Install Webmin to manage your server :)

Install required package for webmin :

wilson@gateway:~$ sudo apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl libmd5-perl


Download webmin from www.webmin.org

wilson@gateway:~$ wget http://prdownloads.sourceforge.net/webadmin/webmin-1.390.tar.gz

Unpack it :

wilson@gateway:~$ tar zxvf webmin-1.390.tar.gz

Install it :

wilson@gateway:~$ cd webmin-1.390
wilson@gateway:~$ sudo ./setup.sh

Follow the instruction.

After finish installation try to browse it. Example : https://192.168.1.2:10000

Done !!! Another Binggo :)

Well, I think this is all for this moment. :) be simple in lives :)

No comments: