Tuesday, June 26, 2007

[Cisco] เราสามารถ limit การ read ของ snmp ได้

เราสามารถ limit การ view ของ snmp ได้โดย

snmp-server view VIEW-NAME OID [included|excluded]

ตัวอย่างเราให้สามารถ read ได้เฉพาะ OID : iso.org.dod.internet.mgmt.mib-2.interfaces เท่านั้น

snmp-server view VIEW_NAME 1.3.6.1.2.1.2 included
snmp-server community TEST view VIEW_NAME ro

Linux:
$snmpwalk -c TEST -v 2c 192.168.1.1
ก็จะเห็นเฉพาะข้อมูลที่เราให้ดูได้

Sunday, June 24, 2007

[Cisco] คิดเล่นๆกับ ACL ต่อ

งั้นถามต่อไปเกี่ยวกับ ACL ที่คล้ายๆกัน

10.0.0.0/16
10.4.0.0/16
10.32.0.0/16
10.36.0.0/16

ต้องการเขียน ACL ที่ match 4 network นี้น่ะครับ เงื่อนไขเหมือนกันคือจะต้องเขียน ACL ให้มีจำนวนบรรทัดน้อยที่สุด
หลังจากจบเรื่อง ACL นี้แล้วทำให้เรารู้เรื่องการคำนวน wildcard mask ครับ

[Cisco] คิดเล่นๆกับ BGP

โจทย์
บริษัท A ใช้ AS100 peering กับบริษัท B AS200 วันหนึ่ง A มีการเปลี่ยน AS จาก 100 เป็น 300 แต่ไม่ต้องการให้ B แก้ไข config ใดๆทั้งสิ้น
จะต้อง config BGP ที่ router ของ A เท่านั้นในการเปลี่ยน AS100 -> AS300 และไม่แก้ไข config ของ B

Saturday, June 23, 2007

[Cisco] ลองคิดเล่นๆ #2

ลองคิดต่อน่ะครับ

โจทย์มี routing
155.1.0.0/24
155.1.1.0/24
155.1.2.0/24
155.1.3.0/24
155.1.4.0/24
155.1.5.0/24
....
155.1.255.0/24

ต้องการเขียน filter เพื่อรับ routing เฉพาะ octet ที่3 เป็นเลขคู่เท่านั้น โดย access-list ที่เขียนใช้จำนวนบรรทัดน้อยที่สุดที่เป็นไปได้
ผลที่ผ่าน acl แล้ว
155.1.0.0/24
155.1.2.0/24
155.1.4.0/24
155.1.6.0/24
155.1.8.0/24
....
155.1.254.0/24

Friday, June 22, 2007

[Cisco] ลองคิดเล่นๆ

ต้องการเพิ่ม user เข้าใน router โดยมีข้อมูลดังนี้
username cisco password cisco?
จะต้องทำอย่างไร

Wednesday, June 20, 2007

[Cisco] Event Manager ไว้ต้องการจับ event แล้วให้ทำคำสั่ง

Event Manager:
เวลาเราต้องการให้ router พบ event บางอย่างแล้วให้ action ตาม command ที่กำหนด ตัวอย่างคือ เมื่อ event manager พบ syslog ที่มี pattern neighbor x.x.x.x Up/Down แล้วให้ทำคำสั่ง

#conf t
event manager applet bgp-down
event syslog pattern "neighbor 192.168.10.2 Down" <-- ตรวจจับ event ของ syslog ที่มี pattern "neighbor 192.168.10.2 Down"
action 1.0 cli command "conf t" <--- ให้เริ่มทำคำสั่ง
action 1.1 cli command "int f0/0"
action 1.2 cli command "no ip policy route-map redirect"
action 1.3 cli command "no ip wccp 80 redirect in"
action 1.4 syslog msg "Alert !!!! policy change by BGP-Down" <--- ให้ส่ง message ไป syslog
action 1.5 mail server "20.20.20.1" to "kitti@mail.xx" from "event-mager@router" subject "Alert neighbor BGP down" body "Neighbor 192.168.10.2 Down" <--- ให้ส่ง mail ด้วย

event manager applet bgp-up
event syslog pattern "neighbor 192.168.10.2 Up"
action 1.0 cli command "conf t"
action 1.1 cli command "int f0/0"
action 1.2 cli command "ip policy route-map redirect"
action 1.3 cli command "ip wccp 80 redirect in
action 1.4 syslog msg "Alert !!! Policy change by BGP-Up"
action 1.5 mail server "20.20.20.1" to "kitti@mail.xx" from "event-mager@router" subject "Alert neighbor BGP up" body "Neighbor 192.168.10.2 Up"

Tuesday, June 12, 2007

[Cisco] Config Q-in-Q (dot1q-tunneling)

Network diagram
Physical connections:
[R1 f0/1]<--->[ g1/0/1 SW1 g1/0/23 -24 ]<--trunk-->[ g1/0/21 -22 SW2 g1/0/23 -24 ] <--trunk-->[ g1/0/23-24 SW3 g1/0/1 ] <--> [ f0/1 R2]

[R1]:
interface f0/1
ip add 192.168.10.1 255.255.255.0
no sh
interface f0/1.100
encap dot1q 100
ip add 192.168.100.1 255.255.255.0

>> R1 verify
sh ip rou
C 192.168.10.0/24 is directly connected, FastEthernet0/1
C 192.168.100.0/24 is directly connected, FastEthernet0/1.100


[R2]:
interface f0/1
ip add 192.168.10.2 255.255.255.0
no sh
interface f0/1.100
encap dot1q 100
ip add 192.168.100.1 255.255.255.0
>> R2 verify
sh ip rou
C 192.168.10.0/24 is directly connected, FastEthernet0/1
C 192.168.100.0/24 is directly connected, FastEthernet0/1.100


[SW1]
system mtu 1504 <------ reload
vlan 100
interface g1/0/1
switchport mo dot1q-tunnel
l2protocol-tunnel point-to-point pagp <--- l2protocol-tunnel this command enable for allow protocols pass throught dot1q-tunnelling
l2protocol-tunnel point-to-point lacp
l2protocol-tunnel point-to-point udld
l2protocol-tunnel cdp
l2protocol-tunnel vtp
l2protocol-tunnel stp
swi access vl 100
no sh
interface rang f0/23 -24
swi tru en dot1q
swi mo tru
no sh
>> SW1 verify
sh int g1/0/1 switchport
sh l2protocol-tunnel
sh int trunk


[SW2]
system mtu 1504 <------ reload
vlan 100
interface rang f0/21 -24
swi tru en dot1q
swi mo tru
no sh

[SW3]
system mtu 1504 <------ reload
vlan 100
interface g1/0/1
switchport mo dot1q-tunnel
l2protocol-tunnel point-to-point pagp
l2protocol-tunnel point-to-point lacp
l2protocol-tunnel point-to-point udld
l2protocol-tunnel cdp
l2protocol-tunnel vtp
l2protocol-tunnel stp
swi access vl 100
no sh
interface rang f0/21 -24
swi tru en dot1q
swi mo tru
no sh


R1:
sh cdp nei <-- can see R2 direct connect
ping 192.168.100.2 <-- can reachable

Wednesday, June 6, 2007

[Cisco] TCL script สำหรับ ping ระบุ source จาก ip ทุกๆ interface

โดยดัดแปลงจาก internetworkexpert
router#tclsh
router(tcl)#
set l [llength [ exec "sh ip int brie | e down|unassig|Status" ]]
set x [ exec "sh ip int brie | e down|unassig|Status" ]
foreach dst {
150.1.1.1
150.1.2.2
} {
set c 0
puts "##########################################"
while {$c<=$l} {
set src [lindex $x $c]
if { [regexp "(^\[0-9]+\.\[0-9]+\.\[0-9]+\.\[0-9]+)" $src] } {
puts "========================================"
puts "ping ip $dst source $src repeat 3"
puts ["ping ip $dst source $src repeat 3"]
}
incr c
}
}

Tuesday, June 5, 2007

[Cisco] ต้องการทำ SPAN port เพื่อ sniff packet

ต้องการทำ SPAN port เพื่อ sniff packet พอไป search เห็นจาก web
How to limit traffic spanned
มีวิธีการ config อยู่หลายวิธีนอกจาก command monitor

Example to monitor HTTP traffic.

c6509(config)# access-list 100 permit tcp any any eq 80
c6509(config)# access-list 101 permit ip any any
c6509(config)# vlan access-map MyCap 10
c6509(config-access-map)# match ip address 101
c6509(config-access-map)# action forward
c6509(config)# vlan access-map MyCap 20
c6509(config-access-map)# match ip address 100
c6509(config-access-map)# action forward capture
c6509(config)# vlan filter MyCap vlan-list 200 , 201
c6509(config)# interface gi3/1
c6509(config-if)# switchport capture

===================

Configuration to capture HTTP traffic on VLAN 20 and send to fa0/24.

c3550(config-access-map)#action forward
c3550(config-access-map)#match ip address SA-TRAFFIC
c3550(config-access-map)#vlan filter RSPAN-VACL vlan-list 100
c3550(config)#interface vlan100
c3550(config-if)#description RSPAN Destination VLAN
c3550(config-if)#no ip address
c3550(config-if)#ip access-list extended SA-TRAFFIC
c3550(config-ext-nacl)#permit tcp any any eq 80
c3550(config)#monitor session 1 source vlan 20 rx
c3550(config)#monitor session 1 destination remote vlan 100 reflector-port fa0/24
c3550(config)#vlan access-map RSPAN-VACL 10


====================

Configuration of Http traffic on VLANs 200 and 201 sent to 3/1.

c6509(config)#ip access-list extended SA-Capture
c6509(config-ext-nacl)# permit tcp any any eq 80
c6509(config-ext-nacl)#exit
c6509(config)#int vlan 200
c6509(config-if)#mls ip ids SA-Capture
c6509(config)#int vlan 201
c6509(config-if)#mls ip ids SA-Capture
c6509(config-if)#int gig3/1
c6509(config-if)#switchport capture