Beranda > @GNS3 Lab, bsci > Menggunakan TCL Script

Menggunakan TCL Script

Tujuan

  • Mempelajar penggunaan TCL scripts untuk memverifikasi koneksi
  • Mengidentifikasi adanya kegagalan koneksi

Topology

tclscript_topology

Langkah 1 : konfigurasi awal

Kopi pastekan konfigurasi berikut pada masing-masing router

R1:

!
hostname R1
!
interface Loopback1
 ip address 10.1.1.1 255.255.255.252
!
interface Loopback2
 ip address 10.1.2.1 255.255.255.252
!
interface Loopback3
 ip address 10.1.3.1 255.255.255.252
!
interface Loopback4
 ip address 10.1.4.1 255.255.255.252
!
interface Serial0/0
 ip address 10.100.12.1 255.255.255.252
 serial restart-delay 0
 clockrate 64000
!
router rip
 version 2
 network 10.0.0.0
 no auto-summary
!
end

R2:

!
hostname R2
!
interface Loopback1
 ip address 10.2.1.1 255.255.255.252
!
interface Loopback2
 ip address 10.2.2.1 255.255.255.252
!
interface Loopback3
 ip address 10.2.3.1 255.255.255.252
!
interface Loopback4
 ip address 10.2.4.1 255.255.255.252
!
!
interface Serial0/0
 no ip address
 serial restart-delay 0
!
router rip
 version 2
 network 10.0.0.0
!
end

Langkah 2 : verifikasi koneksi

Cara paling sederhana untuk memverifkasi koneksi antar mesin adalah dengan menggunakan protokol ICMP (Internet Control Message Protocol).  Telah kita lihat pada konfigurasi R2 diatas, ip address pada interface serial belum dikonfigurasi. Karena belum ada protokol IP yang berjalan pada interface serial R2 sampai ip address dikonfigurasi, maka R1 dan R2 tidak dapat saling bertukar informasi routing.

Cisco IOS versi 12.3(2)T keatas mendukung TCL scripting dalam command line-nya. Berikut contoh script untuk melakukan ping ke semua IP address pada topologi diatas,

foreach address {
10.1.1.1
10.1.2.1
10.1.3.1
10.1.4.1
10.100.12.1
10.2.1.1
10.2.2.1
10.2.3.1
10.2.4.1
10.100.12.2
} {
ping $address
}

Masuk ke mode tclsh dan kopi pastekan script di atas ke dalam shell pada masing-masing router

R1#
R1#tclsh
R1(tcl)#
R1(tcl)#
R1(tcl)#
R1(tcl)#foreach address {
+>(tcl)#10.1.1.1
+>(tcl)#10.1.2.1
+>(tcl)#10.1.3.1
+>(tcl)#10.1.4.1
+>(tcl)#10.100.12.1
+>(tcl)#10.2.1.1
+>(tcl)#10.2.2.1
+>(tcl)#10.2.3.1
+>(tcl)#10.2.4.1
+>(tcl)#10.100.12.2
+>(tcl)#} {
+>(tcl)#ping $address
+>(tcl)#}

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.2.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.3.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.4.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.100.12.1, timeout is 2 seconds:
…..
Success rate is 0 percent (0/5)
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.2.1.1, timeout is 2 seconds:
…..
Success rate is 0 percent (0/5)
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.2.2.1, timeout is 2 seconds:
…..
Success rate is 0 percent (0/5)
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.2.3.1, timeout is 2 seconds:
…..
Success rate is 0 percent (0/5)
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.2.4.1, timeout is 2 seconds:
…..
Success rate is 0 percent (0/5)
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.100.12.2, timeout is 2 seconds:
…..
Success rate is 0 percent (0/5)
R1(tcl)#
R2#
R2#tcls
R2#tclsh
R2(tcl)#
R2(tcl)#
R2(tcl)#foreach address {
+>(tcl)#10.1.1.1
+>(tcl)#10.1.2.1
+>(tcl)#10.1.3.1
+>(tcl)#10.1.4.1
+>(tcl)#10.100.12.1
+>(tcl)#10.2.1.1
+>(tcl)#10.2.2.1
+>(tcl)#10.2.3.1
+>(tcl)#10.2.4.1
+>(tcl)#10.100.12.2
+>(tcl)#} {
+>(tcl)#ping $address
+>(tcl)#}

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:
…..
Success rate is 0 percent (0/5)
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.2.1, timeout is 2 seconds:
…..
Success rate is 0 percent (0/5)
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.3.1, timeout is 2 seconds:
…..
Success rate is 0 percent (0/5)
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.4.1, timeout is 2 seconds:
…..
Success rate is 0 percent (0/5)
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.100.12.1, timeout is 2 seconds:
…..
Success rate is 0 percent (0/5)
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.2.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.2.2.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.2.3.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.2.4.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.100.12.2, timeout is 2 seconds:
…..
Success rate is 0 percent (0/5)
R2(tcl)#

 

Keluar dari shell tcl script dengan perintah tclquit

R1(tcl)#tclquit

 

R2(tcl)#tclquit

Perhatikan pada output diatas, R1 dan R2 tidak dapat mengarahkan ping ke loopback network pada router seberang, hal ini karena masing-masing router R1 dan R2 belum bertukar informasi routing walaupun RIP sudah diaktifkan.

Perhatikan juga bahwa R1 tidak dapat melakukan ping pada ip address interface serialnya sendiri. Dalam koneksi HDLC, Frame Relay, dan ATM, semua paket, termasuk paket ping pada interface lokal harus di forward ke link yang terhubung.

Misalnya, jika R1 berusaha melakukan ping ke addressnya sendiri 10.100.12.1, maka paket ping akan di forward ke serial0/0 meskipun address yang di ping ada pada interface lokal. Misalkan diasumsikan terdapat konfigurasi IP address 10.100.12.2/300 pada interface serial R2. Maka ketika paket ping mencapai ke R2, R2 memeriksa paket tersebut dan mengetahui bahwa paket tersebut tidak ditujukan untuk R2 dan akan memforward balik paket tersebut ke interface serial R1. R1 akan menerima paket tersebut, memeriksanya, dan mengetahui bahwa paket ping tersebut ditujukan untuk ip address interface serial miliknya. R1 akan memberikan respon pada paket ICMP request (ping) tersebut dengan sebuah paket ICMP reply yang ditujukan untuk 10.100.12.1 (addressnya sendiri). R1 mengenkapsulasi paket echo reply tersebut dan memforward keluar melalui interface serial dan sampai pada R2, R2 seperti sebelumnya akan memforward balik paket tersebut karena tidak ditujukan untuknya. Dan akhirnya R1 menerima echo reply tersebut.

Langkah 3: perbaiki koneksi yang gagal

R2#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#int s0/0
R2(config-if)#ip address 10.100.12.2 255.255.255.252
R2(config-if)#^Z
R2#

Setelah ini maka kedua router akan saling bertukar informasi routing, untuk memverifikasinya dapat dilakukan dengan perintah show ip protocols.

R1#show ip protocols
Routing Protocol is “rip”
  Sending updates every 30 seconds, next due in 25 seconds
  Invalid after 180 seconds, hold down 180, flushed after 240
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Redistributing: rip
  Default version control: send version 2, receive version 2
    Interface             Send  Recv  Triggered RIP  Key-chain
    Serial0/0             2     2
    Loopback1             2     2
    Loopback2             2     2
    Loopback3             2     2
    Loopback4             2     2
  Automatic network summarization is not in effect
  Maximum path: 4
  Routing for Networks:
    10.0.0.0
  Routing Information Sources:
    Gateway         Distance      Last Update
    10.100.12.2          120      00:00:24
  Distance: (default is 120)

 

R2#show ip protocols
Routing Protocol is “rip”
  Sending updates every 30 seconds, next due in 24 seconds
  Invalid after 180 seconds, hold down 180, flushed after 240
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Redistributing: rip
  Default version control: send version 2, receive version 2
    Interface             Send  Recv  Triggered RIP  Key-chain
    Serial0/0             2     2
    Loopback1             2     2
    Loopback2             2     2
    Loopback3             2     2
    Loopback4             2     2
  Automatic network summarization is in effect
  Maximum path: 4
  Routing for Networks:
    10.0.0.0
  Routing Information Sources:
    Gateway         Distance      Last Update
    10.100.12.1          120      00:00:13
  Distance: (default is 120)

Setelah kita verifikasi koneksi kedua router berjalan lancar, kita verifikasi kembali koneksi pada semua subnet (interface loopback) dengan scrip tcl sebelumnya

R1#tclsh
R1(tcl)#
R1(tcl)#
R1(tcl)#
R1(tcl)#foreach address {
+>(tcl)#10.1.1.1
+>(tcl)#10.1.2.1
+>(tcl)#10.1.3.1
+>(tcl)#10.1.4.1
+>(tcl)#10.100.12.1
+>(tcl)#10.2.1.1
+>(tcl)#10.2.2.1
+>(tcl)#10.2.3.1
+>(tcl)#10.2.4.1
+>(tcl)#10.100.12.2
+>(tcl)#} {
+>(tcl)#ping $address
+>(tcl)#}

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.2.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.3.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.4.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.100.12.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/35/112 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.2.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/28/108 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.2.2.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/46/88 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.2.3.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/26/56 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.2.4.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/31/56 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.100.12.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/25/100 ms
R1(tcl)#tclquit
R1#
R2#tclsh
R2(tcl)#
R2(tcl)#
R2(tcl)#
R2(tcl)#foreach address {
+>(tcl)#10.1.1.1
+>(tcl)#10.1.2.1
+>(tcl)#10.1.3.1
+>(tcl)#10.1.4.1
+>(tcl)#10.100.12.1
+>(tcl)#10.2.1.1
+>(tcl)#10.2.2.1
+>(tcl)#10.2.3.1
+>(tcl)#10.2.4.1
+>(tcl)#10.100.12.2
+>(tcl)#} {
+>(tcl)#ping $address
+>(tcl)#}

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/48/152 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.2.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/20/40 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.3.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/27/52 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.4.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/33/80 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.100.12.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/24/48 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.2.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.2.2.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.2.3.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.2.4.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.100.12.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/43/112 ms
R2(tcl)#tclquit
R2#

Kesimpulan

Gunakan TCL script untuk memverifikasi semua koneksi yang telah dikonfigurasi diatas dan perhatikan outputnya.  Hal ini bisa menghemat waktu ketika troubleshooting.

Kategori:@GNS3 Lab, bsci
  1. Oktober 5, 2009 pukul 8:34 am

    thanks kang atas tutornya…kapan2 boleh nanya2 kan kang…?

  2. vollynit07uin
    Oktober 16, 2009 pukul 2:52 am

    subhanallah….blok anda sangat bermanfaat untuk saya….banyak ilmu nya….salam kenal….semoga ilmu nya dapat berguna untuk saya dan anda yang menulis artikelini….

  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: