Você está na página 1de 11

Konfigurasi PC Router Menggunakan Linux Debian

Assalamualaikum..... Semangat Pagi....!!!, alhamdulillah pada kesempatan kali ini kita dapat bertemu kembali dalam rangka berbagi setitik ilmu yang kita miliki agar ilmu yang kita miliki tersebut dapat menjadi ilmu yang bermanfaat dan insyaallah akan menjadi bekal kita dihari akhir nanti. Saya ucapkan maaf sebelumnya kepada teman-teman semua yang sudah lama menanti update dari blog ini, dikarenakan kesibukan saya yang begitu padat, sehingga tidak sempat untuk melakukan update blog ini. Pada kesempatan kali ini saya ingin berbagi setitik ilmu yang saya miliki kepada teman-teman semua tentang konfigurasi PC-Router menggunakan linux Debian 4.0 Etch atau Debian 5.0 Lenny, karena konfigurasi PC-Router pada S.O tersebut sama saja. Ok, kita langsung saja, Router...!!!, apa itu router? Router adalah sebuah alat yang berfungsi untuk menghubungkan atau menjembatani dua atu lebih network yang berbeda. Menurut yang saya ketahui, router itu dibagi menjadi dua, yaitu router langsung dan router tidak langsung. router langsung adalah sebuah metode penjaluran yang menggunakan alat untuk merouting /router device (seperti mikrotik router, router board, dll). Sedangkan router tidak langsung adalah sebuah metode penjaluran yang menggunakan alat lain selain router device, seperti PC (PCRouter). Baiklah dari pada bosan baca ocehan saya, mari kita mulai untuk melakukan konfigurasi PCRouter kita menggunakan Linux Debian.

Syarat sebuah PC dapat dijadikan sebagai PC-Router adalah PC tersebut harus memiliki minimal 2 kartu Jaringan. Kenapa?, seperti yang kita sudah bahas diatas bahwa router adalah sebuah alat/device yang berfungsi untuk menghubungkan dua atau lebih network yang berbeda oleh karena itu kenapa syarat sebuah PC-Router harus memiliki minimal 2 kartu jaringa?, karena satu kartu jaringan berfungsi sebagai line in dan satu kartu jaringan lagi berfungsi sebagai line out. Layout Jaringan.

Seperti pada gambar diatas, kita dapat ketahui bahwa: PC-SERVER IP Address : 192.168.1.1 Netmask : 255.255.255.0 Network : 192.168.1.0 PC-ROUTER Eth0: IP Address : 192.168.1.2

Netmask : 255.255.255.0 Network : 192.168.1.0 Eth1: IP Address : 200.100.1.1 Netmask : 255.255.255.0 Network : 200.100.1.0 Baiklah kita mulai konfigurasi. Pastikan PC-Router sudah terinstall System Operasi Linux Debian. 1. Konfigurasi Network interface-nya dengan cara mengetikan pada console: #mcedit /etc/network/interfaces => konfigurasi interfacenya dengan mengetikan script dibawah ini: allow-hotplug eth0 iface eth0 inet static address 192.168.1.2 netmask 255.255.255.0 network 192.168.1.0 gateway 192.196.1.1 broadcast 192.168.1.255 allow-hotplug eth1 iface eth1 inet static address 200.100.1.1 netmask 255.255.255.0 network 200.100.1.0 => Save dan exit dengan cara menekan tombol F10 => YES 2. Aktifkan eth0 dan eth1 dengan cara mendeklarasikan pada file rc.local #mcedit /etc/rc.local => Ketikan script dibawah ini: ifconfig eth0 up ifconfig eth1 up ifconfig eth1 200.100.1.1/24 echo 1 > /proc/sys/net/ipv4/ip_forward iptables -t nat -A POSTROUTING -s 200.100.1.0/24 -d 0/0 -j MASQUERADE iptables -I FORWARD -s 200.100.1.0/24 -d 0/0 -j ACCEPT => Save dan exit dengan cara menekan tombol F10 => YES 3. Aktifkan ip forward di dalam file sysctl.conf #mcedit /etc/sysctl.conf => Hapus pagar yang ada didepan script berikut ini: # net.ipv4.ip_forward=1 => Save dan exit dengan cara menekan tombol F10 => YES 4. Reboot PC-Router agar konfigurasi PC-Router kita dapat berjalan dengan baik. #reboot 5. Setelah di reboot, anda login kembali dengan menggunakan superuser root. kemudian coba ping kepada masing-masing network. alhasil pasti jaringan tersebut dapat saling berkomunikasi

dengan baik. Sekian penjelasan saya tentang konfigurasi PC-Router menggunakan Linux Debian

MEMBANGUN ROUTER PC DAN FIREWALL. Bagi sebagian orang membangun router pc berikut firewall adalah sebuah pekerjaan yang mudah. Namum, bagi adik-adik saya yang baru belajar linux mumkin masih membutuhkan sedikit panduan dan tutorial komputer yang memang khusus membahas cara membangun router pc dan firewall. Artikel tutorial komputer cara membangun router pc dan firewall ini sekaligus saya buat sebagai catatan kecil saya pribadi takut-takut suatu saat lupa karena sudah lama tidak tidak belajar linux. Disini hanya sebuah contoh saja dimana saya menggunakan linux debian, prinsipnya dapat digunakan pada distro GNU/Linux apa saja. Pada artikel ini yang saya lakukan hanya mengkonfigurasi NAT dan IP Forward untuk keperluan sharing internet dan melakukan filtering traffic berdasarkan port service tertentu. Dan hal ini saya lakukan dengan sangat mudah, karena belajar linux memang mudah :D Anda tidak perlu kaget karena disini saya hanya mengkonfigurasi 1 file saya dan memasukan beberapa baris perintah yang akan mengaktifkan IP Forward dan translasi ip address dari jadingan lokal ke jaringan global kita (Router PC). Setelah itu kita akan melakukan filtering traffic (Firewall) terhadap layanan-layanan tertentu yang diwakili oleh port-port logicalnya masing-masing. Ini dapat Anda sesuaikan dengan kebutuhan dan kebijakan Anda sendiri sebagai Networks Administrator. Oke, sekarang langsung saja kita coba untuk membuat router pc dan firewall yaitu dengan meletakan script dibawah ini pada file /etc/rc.local agar script tersebut dapat di load secara otomatis pada saat linux debian kita boot up (hidup). # # Enable IP Forward # echo 1 > /proc/sys/net/ipv4/ip_forward # # Module kernel for Connection Tracking NAT FTP # modprobe ip_nat_ftp # # Flush all rules #

/sbin/iptables -F /sbin/iptables -t nat -F # # NAT # /sbin/iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE # # Default policy Block ALL # /sbin/iptables -P INPUT DROP /sbin/iptables -P OUTPUT DROP /sbin/iptables -P FORWARD DROP # # The loopback interface should accept all traffic # /sbin/iptables -A INPUT -i lo -j ACCEPT /sbin/iptables -A OUTPUT -o lo -j ACCEPT # # INPUT (Protect Our Router from Outside) # /sbin/iptables -I INPUT -m state state RELATED,ESTABLISHED -j ACCEPT /sbin/iptables -A INPUT -p tcp dport 22 -j ACCEPT /sbin/iptables -A INPUT -p tcp dport 53 -j ACCEPT /sbin/iptables -A INPUT -p udp dport 53 -j ACCEPT /sbin/iptables -A INPUT -p udp dport 161:162 -j ACCEPT /sbin/iptables -A INPUT -p icmp -j ACCEPT # # FORWARD (Allowed specific port services on outside) # /sbin/iptables -I FORWARD -m state state RELATED,ESTABLISHED -j ACCEPT /sbin/iptables -A FORWARD -p tcp dport 20:21 -j ACCEPT /sbin/iptables -A FORWARD -p tcp dport 22 -j ACCEPT /sbin/iptables -A FORWARD -p tcp dport 25 -j ACCEPT /sbin/iptables -A FORWARD -p tcp dport 53 -j ACCEPT /sbin/iptables -A FORWARD -p udp dport 53 -j ACCEPT /sbin/iptables -A FORWARD -p tcp dport 80 -j ACCEPT /sbin/iptables -A FORWARD -p tcp dport 110 -j ACCEPT /sbin/iptables -A FORWARD -p tcp dport 143 -j ACCEPT /sbin/iptables -A FORWARD -p tcp dport 443 -j ACCEPT /sbin/iptables -A FORWARD -p tcp dport 5050 -j ACCEPT

/sbin/iptables -A FORWARD -p tcp dport 5100 -j ACCEPT /sbin/iptables -A FORWARD -p icmp -j ACCEPT # # OUTPUT (Allowed specific access from Our Router to Outside) # /sbin/iptables -I OUTPUT -m state state RELATED,ESTABLISHED -j ACCEPT /sbin/iptables -A OUTPUT -p tcp dport 53 -j ACCEPT /sbin/iptables -A OUTPUT -p udp dport 53 -j ACCEPT /sbin/iptables -A OUTPUT -p tcp dport 80 -j ACCEPT /sbin/iptables -A OUTPUT -p icmp -j ACCEPT # [Last update 25/05/09 by utuh^kulaliL] Sampai saat ini tugas kita membangun router pc dan firewall dengan linux debian sudah selesai silahkan reboot atau restart router pc kita dan lihatlah hasilnya :D Bagaimana belajar linux sangat mudah dan menyenangkan bukan. :p Nah, setelah selesai membangun router pc dan firewall agar performa dan kinerja router pc kita tetap terpantau dan termonitoring ada baiknya kita melakukan installasi dan komfigurasi SNMP pada linux debian agar dapat dimonitor setiap saat.

Setting DHCP Server di Debian 4.0


Kembali lagi di distro Debian 4.0 salah satu distro favorit saya. Sekarang saya ingin membahas pembuatan DHCP server dengan debian 4.0. Ok langsung ke cara-caranya aja ya: 1. Buka Konsole 2. Login sebagai root dengan perintah: su3. Kemudian install dhcp-server dengan perintah: apt-get install dhcp 4. Kemudian edit file /etc/dhcp/dhcpd.conf: Berikan tanda pagar pada setiap baris yang belum ditandai pagar,Kemudian tambahkan skrip seperti di bawah ini:

subnet 29.29.29.0 netmask 255.255.255.0 { range 29.29.29.2 29.29.29.254; option subnet-mask 255.255.255.0; option broadcast-address 29.29.29.255; option routers 29.29.29.1; option domain-name ns1.debian.com; option domain-name-servers 172.17.17.100; default-lease-time 21600; max-lease-time 43200; } subnet 192.168.200.0 netmask 255.255.255.0 { } Sedikit akan saya jelaskan maksud dari skrip diatas. subnet 29.29.29.0 netmask 255.255.255.0 digunakan untuk memasukkan subnet dari IP dan netmask yang akan dipakai oleh client dari dhcp server . range 29.29.29.2 29.29.29.254; Digunakan untuk menentukan range dari IP client yaitu dari 29.29.29.2 s/d 29.29.29.254 option subnet-mask 255.255.255.0; Untuk subnet-mask samakan dengan netmask yang ada di baris 1. option broadcast-address 29.29.29.255; Untuk menentukan IP broadcast yang akan digunakan. option routers 29.29.29.1; Digunakan untuk menentukan gateway yang digunakan. option domain-name ns1.debian.com;

Baris ini digunakan untuk memberikan nama dari host dns server option domain-name-servers 172.17.17.100; Baris ini digunakan untuk menentukan ip dari dns server. subnet 192.168.200.0 netmask 255.255.255.0 { } perintah ini digunakan untuk menentukan subnet dari lan card yang terhubung dengan internet. Configuring NTP Server By Default main configuration file located at /etc/ntp.conf Default configuration file looks like below
#/etc/ntp.conf, configuration for ntpd driftfile /var/lib/ntp/ntp.drift statsdir /var/log/ntpstats/ statistics loopstats peerstats clockstats filegen loopstats file loopstats type day enable filegen peerstats file peerstats type day enable filegen clockstats file clockstats type day enable # You do need to talk to an NTP server or two (or three). #server ntp.your-provider.example # pool.ntp.org maps to more than 300 low-stratum NTP servers. # Your server will pick a different set every time it starts up. # *** Please consider joining the pool! *** # *** *** server 0.debian.pool.ntp.org iburst server 1.debian.pool.ntp.org iburst server 2.debian.pool.ntp.org iburst server 3.debian.pool.ntp.org iburst # By default, exchange time with everybody, but don't allow configuration. # See /usr/share/doc/ntp-doc/html/accopt.html for details. restrict -4 default kod notrap nomodify nopeer noquery restrict -6 default kod notrap nomodify nopeer noquery # Local users may interrogate the ntp server more closely. restrict 127.0.0.1 restrict ::1

# Clients from this (example!) subnet have unlimited access, # but only if cryptographically authenticated #restrict 192.168.123.0 mask 255.255.255.0 notrust # If you want to provide time to your local subnet, change the next line. # (Again, the address is an example only.) #broadcast 192.168.123.255 # If you want to listen to time broadcasts on your local subnet, # de-comment the next lines. Please do this only if you trust everybody # on the network! #disable auth #broadcastclient Example Configuration You need to add a number of servers to the server list. The Debian default is pool.ntp.org which works but isn't always amazingly accurate because it makes no attempt to use time servers near you. If you want more accuracy use the time servers either on your continent (for instance europe.pool.ntp.org) or your country (for instance uk.pool.ntp.org) one of your local country servers.The optimal number of servers to listen to is three but two will also give a good accuracy. If your ISP runs a time server for you it is worth including it in your server list as it will often be more accurate than the pooled servers and will help keep the load down on the pool. I am using the following two servers for my configuration server ntp0.pipex.net server ntp1.pipex.net Restrict the type of access you allow these servers. In this example the servers are not allowed to modify the run-time configuration or query your Linux NTP server. restrict otherntp.server.org mask 255.255.255.255 nomodify notrap noquery restrict ntp.research.gov mask 255.255.255.255 nomodify notrap noquery The mask 255.255.255.255 statement is really a subnet mask limiting access to the single IP address of the remote NTP servers. If this server is also going to provide time for other computers, such as PCs, other Linux servers and networking devices, then you'll have to define the networks from which this server will accept NTP synchronization requests. You do so with a modified restrict statement removing the noquery keyword to allow the network to query your NTP server. The syntax is: restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap In this case the mask statement has been expanded to include all 255 possible IP addresses on the local network.

We also want to make sure that localhost (the universal IP address used to refer to a Linux server itself) has full access without any restricting keywords restrict 127.0.0.1 Save the file and exit Now you need to run the ntpdate command against your server #ntpdate ntp0.pipex.net restart NTP for these settings to take effect using the following command #/etc/init.d/ntp restart You can now configure other Linux hosts on your network to synchronize with this new master NTP server in a similar fashion. Determining If NTP Is Synchronized Properly Use the ntpq command to see the servers with which you are synchronized. It provided you with a list of configured time servers and the delay, offset and jitter that your server is experiencing with them. For correct synchronization, the delay and offset values should be non-zero and the jitter value should be under 100. #ntpq -p Output looks like below

A star by any one of the names means that the system clock is synchronising with the NTP clock. If you don't have a star (as in the example above) it means that the clocks are unreachable, already synchronized to this server or has an outrageous synchronization distance. Try running ntpdate (you will need to stop the ntp server) with your first ntp server as an argument. This will set your system clock fairly accuratly and mean that the server will be able to choose a clock to synchronize with. Firewall Configuration for NTP NTP servers communicate with one another using UDP with a destination port of 123. Unlike most UDP protocols, the source port isn't a high port (above 1023), but 123 also. You'll have to allow UDP traffic on source/destination port 123 between your server and the Stratum 1/2 server with which you are synchronizing. NTP Client Configuration

If you want to configure ntp client you need to install the following packages #apt-get install ntp ntp-simple ntpdate Configuring NTP client You need to edit the /etc/ntp.conf file you need to point the following settings to NTP server ip address Server configuration settings server 192.168.1.1 Restrict the type of access you allow these servers. In this example the servers are not allowed to modify the run-time configuration or query your Linux NTP server. restrict default notrust nomodify nopeer Localhost configuration restrict 192.168.1.1 In this case the mask statement has been expanded to include all 255 possible IP addresses on the local network. We also want to make sure that localhost (the universal IP address used to refer to a Linux server itself) has full access without any restricting keywords restrict 127.0.0.1 Now you need to save and exit the file run ntpdate command against your server ntpdate 192.168.1.1 Restart ntp service using the following command /etc/init.d/ntp restart If you use the date command to change time, it is worth setting also the hardware clock to the correct time. Otherwise, the time is wrong after the next reboot, since the hardware clock keeps the time when power is turned off. When the clock in the operating system shows the correct time, set the hardware clock like this #hwclock --systohc se the ntpq command to see the servers with which you are synchronized

#ntpq #ntpdc -p

NTP atau Network Time Protocol di Debian itu cara settingnya kira-kira begini: (Dari Command Prompt / Terminal Console) 1. Install NTP Server nya: apt-get install ntp ntpdate ntp-server (Kalau mau pakai aptitude sebagai pengganti apt-get juga boleh) 2. Ubah konfigurasi NTP server nya: nano /etc/ntp.conf 2.a. Pada baris "server ..." buat baris baru yang isinya "server id.pool.ntp.org" dan remark (beri awalan #) atau hapus baris "server ..." lainnya. Ini supaya sinkronisasi time nya ke lokasi server Indonesia saja. 2.b. Tambahkan baris "restrict a.b.c.d mask 255.255.255.0 nomodify notrap" dimana a.b.c.d adalah network IP anda (misalnya 192.168.1.0). Ini gunanya untuk memperbolehkan IP di jaringan anda untuk mengakses NTP Server anda. Kalau tidak mau repot, bisa menggunakan "restrict 0.0.0.0 mask 0.0.0.0 nomodify notrap" untuk memperbolehkan semua IP. 2.c. Save file nya, dan exit 3. Sinkronisasikan NTP Server anda ke NTP Server induk: ntpdate id.pool.ntp.org 4. Restart NTP Server nya: /etc/init.d/ntp restart

Sudah selesai deh konfigurasi NTP Server di Debian. Untuk memastikan bahwa NTP nya sudah sinkron, bisa gunakan perintah: ntpq -d

Você também pode gostar