Kamis, 19 Februari 2009

sting router menggunakan linux ubuntu 8.04

Meng-aktikan root
Dengan perintah di bawah ini….

# sudo passwd —enter (masukin pass sekarang, buat pass baru untuk root)
# su — enter (masukin pass root)


seting ip address, gunakan program editing kesayangan anda, disini saya pakai
#nano /etc/network/interface

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.254
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168..1.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 202.134.0.155
dns-search smkcokro.kotamobagu.org
auto eth1
iface eth1 inet static
address 192.168.0.1
netmask 255.255.255.0


Restart network

root@ubuntu:~# /etc/init.d/networking restart
* Reconfiguring network interfaces… [ OK ]


Lihat hasil dari configurasi ip address dengan perintah
root@ubuntu:~# ifconfig

root@ubuntu:~# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0c:29:c9:2f:37
inet addr:192.168.1.254 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fec9:2f37/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:882 errors:0 dropped:0 overruns:0 frame:0
TX packets:314 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:95253 (93.0 KB) TX bytes:36154 (35.3 KB)
Interrupt:17 Base address:0×1400

eth1 Link encap:Ethernet HWaddr 00:0c:29:c9:2f:41
inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fec9:2f41/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:12 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1378 (1.3 KB) TX bytes:328 (328.0 B)
Interrupt:18 Base address:0×1480

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

test ping ke geteway isp
root@ubuntu:~# ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.655 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.348 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.335 ms

ok.

Lanjut dengan seting DNS

root@ubuntu:~# nano /etc/resolv.conf

nameserver 192.168.1.1 (ganti dengan IP DNS dari ISP)

test ping ke internet, contoh ping ke google

root@ubuntu:~# ping gogole.com
PING gogole.com (64.233.161.104) 56(84) bytes of data.
64 bytes from od-in-f104.google.com (64.233.161.104): icmp_seq=1 ttl=235 time=293 ms
64 bytes from od-in-f104.google.com (64.233.161.104): icmp_seq=2 ttl=235 time=294 ms

Ok,

Update ubuntu

root@ubuntu:~# apt-get update
root@ubuntu:~# apt-get upgrade (akan memakan waktu) tunggu sampai selesai

Dilanjutakan dengan Seting Internet sharing,
Ket configurasi iptables NAT

--> IP ke internet = 192.168.1.254 interfaces (eth0)

--> IP ke LAN = 192.168.0.1 interfaces (eth1),

iptables -A POSTROUTING -j MASQUERADE -t nat -s (iplan) -o (interface ke internet)

iptables -A FORWARD -i (interface ke LAN) -s (ipLAN) -j ACCEPT

echo 1 > /proc/sys/net/ipv4/ip_forward (untuk mengaktifkan ip forward)

Dari keterangan diatas bisa kita ambil contoh dari parameter ip address yang kita seting diatas yaitu :

IP ke internet = 192.168.1.254 interfaces eth0

IP ke LAN = 192.168.0.1 interfaces eth1, jadi hasilnya seperti dibawah

iptables -A POSTROUTING -j MASQUERADE -t nat -s 192.168.0.0/24 -o eth0

iptables -A FORWARD -i eth1 -s 192.168.0.0/24 -j ACCEPT

Buka file /etc/rc.local, file ini sama fungsinya dengan autoexec.bat di window, fiel ini akan di jalankan waktu proses starup,

root@ubuntu:~# nano /etc/rc.local

sisipkan baris perintah ip tables diatas di bawah kata exit 0

IP ke internet = 192.168.1.254 interfaces eth0

IP ke LAN = 192.168.0.1 interfaces eth1, jadi hasilnya seperti dibawah

root@ubuntu:~# iptables -A POSTROUTING -j MASQUERADE -t nat -s 192.168.0.0/24 -o eth0
root@ubuntu:~# iptables -A FORWARD -i eth1 -s 192.168.0.0/24 -j ACCEPT

Mengaktifkan ip_forward

root@ubuntu:~# echo 1 > /proc/sys/net/ipv4/ip_forward

jalankan perintah ini biar ngak perlu restart

root@ubuntu:~# nano /etc/rc.local

Buka file /etc/rc.local, file ini sama fungsinya dengan autoexec.bat di window, fiel ini akan di jalankan waktu proses starup,

root@ubuntu:~# nano /etc/rc.local

sisipkan baris perintah ip tables diatas di bawah kata exit 0


Kemudian ketikan scrip iptables ke file rc.local
Hasilnya jadi seperti di bawah ini….

#!/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.

iptables -A POSTROUTING -j MASQUERADE -t nat -s 192.168.0.0/24 -o eth0

iptables -A FORWARD -i eth1 -s 192.168.0.0/24 -j ACCEPT

exit 0

Selanjutnya reboot system computer anda…
Dengan perintah

root@ubuntu:~# reboot

Tidak ada komentar: