1. Siapkan 2 buah kartu jaringan dan pasang di komputer yang mau dijadikan Gateway. Komputer sudah terinstalasi Fedora Core 11. Dan Anda bisa sebagai root.
2. eth0 beri IP Address = 192.168.2.1, Subnet Mask = 255.255.255.0, Gateway = 202.46.3.yy. DNS bisa dikosongkan. Isi Gateway disamakan dengan IP Address eth1.
3. Pasang kabel UTP ke suatu switch, katakan Switch1
4. eth1 beri IP Address = 202.46.3.yy, Subnet Mask = 255.255.255.240, Gateway = 202.46.3.xx. Isi DNS sesuai dengan petunjuk dari ISP (provider). Nilai IP Address, Subnet Mask dan gateway juga ikut petunjuk dari ISP (provider).
5. Pasang kabel UTP ke ISP (entah via modem atau router)
6. Aktifkan ke-2 interface di atas, lalu cek dengan ifconfig.
# /etc/rc.d/init.d/network restart
# ifconfig
6. Anggap paket iptables sudah terinstalasi di Fedora Core 11.
7. Jalankan ip_forward
# echo 1 > /proc/sys/net/ipv4/ip_forward
8. Hentikan iptables
# /etc/init.d/iptables stop
9. Jalankan 2 perintah iptables di bawah ini.
# iptables -A FORWARD -s 192.168.2.0/24 -j ACCEPT
# iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -j MASQUERADE
10. Test dari komputer client untuk PING, FTP, SSH, HTTP. Tancapkan kabel UTP dari Client1 ke Switch1. Cleint beri IP Address = 192.168.2.3, Subnet mask = 255.255.255.0, Gateway = 192.168.2.1 (samakan dengan alamat eth0-nya gateway).
Keterangan :
# adalah prompt root
Contoh tampilan di sisi Gateway
[msmunir@svec ~]$ su -
Password:
[root@svec ~]# ifconfig
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:82 errors:0 dropped:0 overruns:0 frame:0
TX packets:82 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:6740 (6.5 KiB) TX bytes:6740 (6.5 KiB)
[root@svec ~]# /etc/rc.d/init.d/network restart
Mematikan antarmuka loopback: [ OK ]
Mengaktifkan antarmuka loopbak: [ OK ]
Menghidupkan antarmuka eth0: [ OK ]
Menghidupkan antarmuka eth1: [ OK ]
[root@svec ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:1C:C0:7B:60:C0
inet addr:192.168.2.1 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::21c:c0ff:fe7b:60c0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:26 errors:0 dropped:0 overruns:0 frame:0
TX packets:22 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2320 (2.2 KiB) TX bytes:3899 (3.8 KiB)
Interrupt:28 Base address:0x8000
eth1 Link encap:Ethernet HWaddr 00:18:F3:C9:0D:DC
inet addr:202.46.3.yy Bcast:202.46.3.95 Mask:255.255.255.0
inet6 addr: fe80::218:f3ff:fec9:ddc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:521 errors:0 dropped:0 overruns:0 frame:0
TX packets:17 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:31260 (30.5 KiB) TX bytes:3135 (3.0 KiB)
Interrupt:21
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:82 errors:0 dropped:0 overruns:0 frame:0
TX packets:82 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:6740 (6.5 KiB) TX bytes:6740 (6.5 KiB)
[root@svec ~]# echo 1 > /proc/sys/net/ipv4/ip_forward
[root@svec ~]# /etc/init.d/iptables stop
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
[root@svec ~]# iptables -A FORWARD -s 192.168.2.0/24 -j ACCEPT
[root@svec ~]# iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -j MASQUERADE
[root@svec ~]#
[root@svec ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
202.46.3.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1
0.0.0.0 202.46.3.xx 0.0.0.0 UG 0 0 0 eth1
[root@svec ~]#
route del -net 10.13.21.0 netmask 255.255.255.0 gw 192.168.10.254 eth0
route del -net 169.254.0.0 netmask 255.255.0.0 gw 0.0.0.0 eth0
[root@svec ~]# route del -net 169.254.0.0 netmask 255.255.0.0 gw 0.0.0.0 eth0
[root@svec ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
202.46.3.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1
0.0.0.0 202.46.3.xx 0.0.0.0 UG 0 0 0 eth1
[root@svec ~]#
route del -net 169.254.0.0 netmask 255.255.0.0 gw 0.0.0.0 eth1
[root@svec ~]# route del -net 169.254.0.0 netmask 255.255.0.0 gw 0.0.0.0 eth1
[root@svec ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
202.46.3.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 202.46.3.xx 0.0.0.0 UG 0 0 0 eth1
[root@svec ~]#
Kesimpulan :
Jalankan 6 langkah sederhana ini
# /etc/rc.d/init.d/network restart
# ifconfig
# echo 1 > /proc/sys/net/ipv4/ip_forward
# /etc/init.d/iptables stop
# iptables -A FORWARD -s 192.168.2.0/24 -j ACCEPT
# iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -j MASQUERADE
Untuk test dari komputer client, sebaiknya siapkan :
2. eth0 beri IP Address = 192.168.2.1, Subnet Mask = 255.255.255.0, Gateway = 202.46.3.yy. DNS bisa dikosongkan. Isi Gateway disamakan dengan IP Address eth1.
3. Pasang kabel UTP ke suatu switch, katakan Switch1
4. eth1 beri IP Address = 202.46.3.yy, Subnet Mask = 255.255.255.240, Gateway = 202.46.3.xx. Isi DNS sesuai dengan petunjuk dari ISP (provider). Nilai IP Address, Subnet Mask dan gateway juga ikut petunjuk dari ISP (provider).
5. Pasang kabel UTP ke ISP (entah via modem atau router)
6. Aktifkan ke-2 interface di atas, lalu cek dengan ifconfig.
# /etc/rc.d/init.d/network restart
# ifconfig
6. Anggap paket iptables sudah terinstalasi di Fedora Core 11.
7. Jalankan ip_forward
# echo 1 > /proc/sys/net/ipv4/ip_forward
8. Hentikan iptables
# /etc/init.d/iptables stop
9. Jalankan 2 perintah iptables di bawah ini.
# iptables -A FORWARD -s 192.168.2.0/24 -j ACCEPT
# iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -j MASQUERADE
10. Test dari komputer client untuk PING, FTP, SSH, HTTP. Tancapkan kabel UTP dari Client1 ke Switch1. Cleint beri IP Address = 192.168.2.3, Subnet mask = 255.255.255.0, Gateway = 192.168.2.1 (samakan dengan alamat eth0-nya gateway).
Keterangan :
# adalah prompt root
Contoh tampilan di sisi Gateway
[msmunir@svec ~]$ su -
Password:
[root@svec ~]# ifconfig
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:82 errors:0 dropped:0 overruns:0 frame:0
TX packets:82 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:6740 (6.5 KiB) TX bytes:6740 (6.5 KiB)
[root@svec ~]# /etc/rc.d/init.d/network restart
Mematikan antarmuka loopback: [ OK ]
Mengaktifkan antarmuka loopbak: [ OK ]
Menghidupkan antarmuka eth0: [ OK ]
Menghidupkan antarmuka eth1: [ OK ]
[root@svec ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:1C:C0:7B:60:C0
inet addr:192.168.2.1 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::21c:c0ff:fe7b:60c0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:26 errors:0 dropped:0 overruns:0 frame:0
TX packets:22 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2320 (2.2 KiB) TX bytes:3899 (3.8 KiB)
Interrupt:28 Base address:0x8000
eth1 Link encap:Ethernet HWaddr 00:18:F3:C9:0D:DC
inet addr:202.46.3.yy Bcast:202.46.3.95 Mask:255.255.255.0
inet6 addr: fe80::218:f3ff:fec9:ddc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:521 errors:0 dropped:0 overruns:0 frame:0
TX packets:17 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:31260 (30.5 KiB) TX bytes:3135 (3.0 KiB)
Interrupt:21
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:82 errors:0 dropped:0 overruns:0 frame:0
TX packets:82 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:6740 (6.5 KiB) TX bytes:6740 (6.5 KiB)
[root@svec ~]# echo 1 > /proc/sys/net/ipv4/ip_forward
[root@svec ~]# /etc/init.d/iptables stop
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
[root@svec ~]# iptables -A FORWARD -s 192.168.2.0/24 -j ACCEPT
[root@svec ~]# iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -j MASQUERADE
[root@svec ~]#
[root@svec ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
202.46.3.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1
0.0.0.0 202.46.3.xx 0.0.0.0 UG 0 0 0 eth1
[root@svec ~]#
route del -net 10.13.21.0 netmask 255.255.255.0 gw 192.168.10.254 eth0
route del -net 169.254.0.0 netmask 255.255.0.0 gw 0.0.0.0 eth0
[root@svec ~]# route del -net 169.254.0.0 netmask 255.255.0.0 gw 0.0.0.0 eth0
[root@svec ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
202.46.3.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1
0.0.0.0 202.46.3.xx 0.0.0.0 UG 0 0 0 eth1
[root@svec ~]#
route del -net 169.254.0.0 netmask 255.255.0.0 gw 0.0.0.0 eth1
[root@svec ~]# route del -net 169.254.0.0 netmask 255.255.0.0 gw 0.0.0.0 eth1
[root@svec ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
202.46.3.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 202.46.3.xx 0.0.0.0 UG 0 0 0 eth1
[root@svec ~]#
Kesimpulan :
Jalankan 6 langkah sederhana ini
# /etc/rc.d/init.d/network restart
# ifconfig
# echo 1 > /proc/sys/net/ipv4/ip_forward
# /etc/init.d/iptables stop
# iptables -A FORWARD -s 192.168.2.0/24 -j ACCEPT
# iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -j MASQUERADE
Untuk test dari komputer client, sebaiknya siapkan :
- Program gFTP
- Program Firefox
- Alamat komputer di luar sana yang bisa di-SSH (gak harus)
- Alamat host di luar sana yang bisa di-ping, bisa juga www.detik.com
No comments:
Post a Comment