20 Desember 2008

UBUNTU 8.10 Home Network (NAT)

Akhirnya sadar -- setelah google sini/google sana -- bahwa paket network-manager ubuntu mengabaikan konfigurasi di /etc/network/interfaces. Jika menginginkan alamat IP statik, terpaksa harus uninstall paket tersebut. Sisanya, seperti biasa... OK... OK..., saya akan menjabarkan konfigurasi dari 'pamulang3', sebuah Pentium4/HT yang mendistribusikan internet ke dalam rumah di Pamulang.

(1) Uninstall network-manager dan install dhcp3-server:
# apt-get remove network-manager
# apt-get install dhcp3-server

(2) Edit /etc/network/interfaces:
auto lo eth0 eth1
iface lo inet loopback
iface eth0 inet dhcp
iface eth1 inet static
network 192.168.0.0
address 192.168.0.1
broadcast 192.168.0.255
netmask 255.255.255.0
(3) Edit /etc/sysctl.conf ubah:
net.ipv4.ip_forward=1
(4) Edit /etc/dhcp3/dhcpd.conf; isi ISI-IP-DNS-1 dan ISI-IP-DNS-2 dengan alamat DNS server terkait.

option routers 192.168.0.1;
ignore client-updates;
option domain-name-servers ISI-IP-DNS-1, ISI-IP-DNS-2;
default-lease-time 1200;
max-lease-time 3600;
authoritative;
log-facility local7;
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.20 192.168.0.250;
option routers 192.168.0.1;
option ip-forwarding off;
option broadcast-address 192.168.0.255;
option subnet-mask 255.255.255.0;
# static IP
host pamulang-mobile {
hardware ethernet 00:1b:38:da:5a:d6;
fixed-address 192.168.0.2;
}
}
subnet 192.168.1.0 netmask 255.255.255.0 {
}
subnet 192.168.2.0 netmask 255.255.255.0 {
}
(5) Edit /etc/rc.local:

#!/bin/sh -e
#
# rc.local
#
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
/bin/sleep 1;
/sbin/iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
/bin/sleep 1;
/sbin/iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
/bin/sleep 2;
(6) Reboot saja sekalian, mengecek apakah sysctl.conf-nya berfungsi.

revisi 10.11.01-03