Biasanya bikin router pakai freebsd, baru sekarang membuat router pakai ubuntu. kali ini ubuntu yang saya gunakan versi 9.10. kenapa saya pakai ubuntu, ni karena kebutuhan di warnet baru. selain untuk router juga untuk proxy, file sharing, data user, data server dns server, ftp. hem... satu komputer di suruh kerja keras... :D. tapi inilah yang terjadi. karena sikon yang memaksakan seperti ini. OkKellah Kaluo beggitu... langsung lanjut aja.
Tentunya komputer udah terinstall ubuntu. pasang 2 interface dalam hal ini eth0 arah ke client dengan ip 192.168.1.253 dan eth1 arah ke ISP atau bisa jg kalu menggunakan koneksi speedy arahin ke modem.
buka dengan pico lewat terminal konfigurasi network agar static, jadi saat komputer restart konfigurasi tidak berubah.
auto lo
server@nasrul:~$ sudo su -
[sudo] password for server:***** <-- masukkan password root root@nasrul:~# pico /etc/network/interfaces auto eth0 iface eth0 inet static address 192.168.1.253 network 192.168.1.0 netmask 255.255.255.0 broadcast 192.168.1.255 #settingan untuk eth1 (untuk client) auto eth1 iface eth1 inet static address 222.124.XXX.XXX network 222.124.XXX.0 netmask 255.255.255.240 broadcast 222.124.XXX.255 gateway 222.124.XXX.XXX
simpan konfigurasi, kemudian restart network interface komputer.
root@nasrul:~#sudo /etc/init.d/networking restart
* Reconfiguring network interfaces... [ OK ]
edit nameserver di /etc/resolv.conf fungsi nameserver ini untuk menterjemahkan alamt domain ke ip dan sebaliknya antara server dengan publik.
root@nasrul:~#pico /etc/resolv.conf
# Generated by NetworkManager
nameserver 222.124.XXX.XXX
kemudian setting router sebagai dns client. agar client cukup memasukan primary dns dari ip router jadi nantinya ip gateway & ip primary dns client sama. konfigurasi ini menggunakan bind9. untuk install bind9 dengan langkah - langkah sebagai berikut :
root@nasrul:~#sudo apt-get install bind9
setelah installasi selesai masuk ke direktori bind di /etc/bind/ isi file bind sebagai berikut :
root@nasrul:~# cd /etc/bind
root@nasrul:/etc/bind# ls -al
total 68
drwxr-sr-x 2 root bind 4096 2010-01-06 19:13 .
drwxr-xr-x 138 root root 12288 2010-01-06 19:34 ..
-rw-r--r-- 1 root root 237 2009-08-20 05:00 db.0
-rw-r--r-- 1 root root 271 2009-08-20 05:00 db.127
-rw-r--r-- 1 root root 237 2009-08-20 05:00 db.255
-rw-r--r-- 1 root root 353 2009-08-20 05:00 db.empty
-rw-r--r-- 1 root root 270 2009-08-20 05:00 db.local
-rw-r--r-- 1 root root 2940 2009-08-20 05:00 db.root
-rw-r--r-- 1 root bind 463 2009-08-20 05:00 named.conf
-rw-r--r-- 1 root bind 490 2009-08-20 05:00 named.conf.default-zones
-rw-r--r-- 1 root bind 165 2009-08-20 05:00 named.conf.local
-rw-r--r-- 1 root bind 595 2010-01-06 19:13 named.conf.options
-rw-r--r-- 1 root bind 571 2010-01-06 19:13 named.conf.options~
-rw-r----- 1 bind bind 77 2010-01-06 19:02 rndc.key
-rw-r--r-- 1 root root 1317 2009-08-20 05:00 zones.rfc1918
edit file yang tercetak tebal. sesuaikan konfigurasinya sebagai berikut :
options {
directory "/var/cache/bind";
// If there is a firewall between you and nameservers you want
// to talk to, you may need to fix the firewall to allow multiple
// ports to talk. See http://www.kb.cert.org/vuls/id/800113
// If your ISP provided one or more IP addresses for stable
// nameservers, you probably want to use them as forwarders.
// Uncomment the following block, and insert the addresses replacing
// the all-0's placeholder.
forwarders {
222.124.XXX.XXX;
};
auth-nxdomain no; # conform to RFC1035
listen-on-v6 { 127.0.0.1;192.168.1.253;any; };
};
tahapan selanjutnya konfigurasi NAT menggunakan iptables.
root@nasrul:~#/sbin/iptables -t nat -A POSTROUTING -s 192.168.1.0/255.255.255.0 -d 0/0 -j MASQUERADE
Blok port yang rentan untuk serangan virus
root@nasrul:~#/sbin/iptables -A FORWARD -p tcp --dport 135:139 -o eth1 -j DROP
root@nasrul:~#/sbin/iptables -A FORWARD -p udp --dport 135:139 -o eth1 -j DROP
root@nasrul:~#/sbin/iptables -A OUTPUT -p tcp --sport 135:139 -o eth -j DROP
root@nasrul:~#/sbin/iptables -A OUTPUT -p udp --sport 135:139 -o eth1 -j DROP
selesai ok reboot pc router dengan perintah reboot. kalu mau menambahkan squid bisa di baca
di sini tentang install squidisi file rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
#exit 0
echo 1 > /proc/sys/net/ipv4/ip_forward
/usr/local/etc/squid/sbin/squid -D
/sbin/iptables -A FORWARD -p tcp --dport 135:139 -o eth1 -j DROP
/sbin/iptables -A FORWARD -p udp --dport 135:139 -o eth1 -j DROP
/sbin/iptables -A OUTPUT -p tcp --sport 135:139 -o eth -j DROP
/sbin/iptables -A OUTPUT -p udp --sport 135:139 -o eth1 -j DROP
/sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
/sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j DNAT --to-destination 192.168.1.253:3128