Thursday, April 5, 2007

[Cisco] จะ enable portchannel บน sup กับ module อื่น

ผมจะ enable portchannel บน interface ที่อยู่บน sup กับ interface GiE ที่ module อื่นปรากฏว่าพอผม add port ที่อยู่บน sup เข้าไปเกิด error
Apr 5 08:53:31: %EC-SP-5-CANNOT_BUNDLE2: Gi6/1 is not compatible with Gi1/11 and will be suspended (qos-card types of Gi6/1 do not match Gi1/11)

แก้ปัญหาโดย
conf t
interface port-channel 5
no mls qos channel-consistency
end
wr
ก็จะสามารถ bundle เข้าไปได้ครับ

Monday, April 2, 2007

[Troubleshoot] ตรวจสอบว่า server เปิด port หรือเปล่า?

ผมมีปัญหาอยู่ว่าใช้งาน www ว่าเปิดใช้งานได้หรือเปล่า?
ผมจึง test ไปที่ port 80
#telnet www.google.co.th 80
GET / HTTP/1.0
Host: www.google.co.th

HTTP/1.0 200 OK
Cache-Control: private
Content-Type: text/html; charset=windows-874
Set-Cookie: PREF=ID=5b1649e656f8f15d:TM=1175486984:LM=1175486984:S=N34yIfvZSGMzc36h; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.co.th
Server: GWS/2.1
Date: Mon, 02 Apr 2007 04:09:44 GMT
Connection: Close
<----- DATA ------>

Friday, March 30, 2007

[Linux] เวลาเอาไฟล์จาก dos มาใช้บน linux แล้วเห็น ^M

มักจะมีปัญหาว่าเอาไฟล์จาก dos มาใช้ใน linux แล้วเห็นเป็น ^M อยากจะเอามันออก

#col -bx < dos-filename > new-filename

[Linux] จะใช้ console ผ่าน com1 กับ linux

อยากทำเท่ config linux ผ่าน console เหมือนพวก router
vi /etc/grub.conf
serial --unit=0 --speed=9600
terminal --timeout=15 console serial

บรรทัด kernel ต่อท้ายบรรทัดด้วย console=tty0 console=ttyS0

ถ้า loader ใช้ lilo
vi /etc/lilo.conf
serial = 0,9600n8
append = "console=ttyS0,9600n8"

vi /etc/inittab
S1:12345:respawn:/sbin/agetty -L ttyS0 9600 vt100

vi /etc/securetty
! เอา remark ออกตรง ttyS0 เพื่อให้ root สามารถ login ได้

[Linux] เคยดู log ของ Squid แล้วอยากดู timestamp ที่มันรู้เรื่องหน่อย

vi converttime.pl
#!/usr/bin/perl -p
s/^\d+\.\d+/localtime $&/e;

เวลาใช้งาน
#./converttime.pl access-log

ค่อยรู้เรื่องหน่อย

[Cisco] ใช้ Cisco ต่อ adsl modem แล้ว dial ออกไป

นานมาแล้วเรื่องมันมีอยู่ว่ามี router cisco อยู่ 1 ตัวถ้าไปซื้อ adsl module มันก็จะแพงไป พอดีเราก็มี adsl modem ที่ได้ฟรีมา ดีเลยเราใช้ cisco router ใช้ connect ผ่าน adsl modem ออกไป เยี่ยมเลยถ้าทำ nat ก็ work ไปเลย

PC--- f0/1 { Cisco } f0/0 -------(adsl modem)-------------adsl line

conf t

ip dhcp pool default
network 192.168.10.0 255.255.255.0
default-router 192.168.10.1
dns-server 203.144.y.y 203.144.x.x

interface f0/0
no ip address
no ip proxy-arp
pppoe enable group global
pppoe-client dial-pool-number 1

interface f0/1
ip add 192.168.10.1 255.255.255.0
ip tcp adjust-mss 1452
ip nat inside
no shut

no shutdown
interface dialer1
ip address negotiate
ip mtu 1492
encapsulation ppp
no ip proxy-arp
dialer pool 1
dialer-group 1
ppp chap hostname USERNAME
ppp chap password PASSWORD
ppp pap sent-username USERNAME password PASSWORD

ip nat inside source list 1 interface dialer1 overload
access-list 1 permit 192.168.10.0 0.0.0.255
ip route 0.0.0.0 0.0.0.0 dialer1
dialer-list 1 protocol ip permit

!-------------------------------------------------------------

ลองเอาไปใช้ดูครับ

[Cisco] Config Cisco เป็น VPN/IPSec Server

ผมใช้ VPN Client ของ Cisco connect มาที่ Cisco7200 ip x.x.x.x เพื่อใช้ resource ที่อยู่ใน LAN
Group = CISCO_GROUP
Group Password = cisco_group
Username = cisco
Password = cisco

aaa authentication login vpn_authen local
aaa authorization network vpn_group_authen local
!
username cisco password cisco
!
crypto isakmp policy 1
encr 3des
authentication pre-share
group 2
!
crypto isakmp client configuration group CISCO_GROUP
key cisco_group
pool VPN_CLIENT_POOL
acl 102
!
crypto ipsec transform-set vpn_client esp-3des esp-sha-hmac
crypto ipsec df-bit clear
!
crypto dynamic-map dynmap 50
set transform-set vpn_client
reverse-route
!
crypto map vpn client authentication list vpn_authen
crypto map vpn isakmp authorization list vpn_group_authen
crypto map vpn client configuration address respond
crypto map vpn 50 ipsec-isakmp dynamic dynmap
!
interface FastEthernet0/0
description ## LAN ##
ip address 172.31.1.254 255.255.255.0
duplex half

!
interface Serial0/0
description ## Internet ##
ip address x.x.x.x y.y.y.y
crypto map vpn
!
ip local pool VPN_CLIENT_POOL 172.31.3.1 172.31.3.10
!
access-list 102 permit ip 172.31.1.0 0.0.0.255 172.31.3.0 0.0.0.255
!

[Private] ขอขอบคุณลูกพี่

ขอขอบคุณลูกพี่ Google ที่ทำให้ผมทำ Blog และ share ความรู้ทุกอย่างครับ
ขอบคุณพี่ Google อีกครั้งครับ

แสดงความคิดเห็นสำหรับ Blog ของผม

ช่วยแสดงความคิดเห็นหน่อยครับ อาจจะแนะนำว่าผมเขียนผิด หรือไม่ดีตรงไหนผมจะได้ปรับปรุงผลงานต่อไป ขอบคุณทุกคนที่เข้ามาเยี่ยมชมและแสดงความคิดเห็น หรือจะให้ผมช่วยอะไรได้บ้าง ก็บอกกันมา(ถ้าทำได้)......

[Cisco] เคยรำคาญกันบ้างไหมเวลาเราพิมพ์ command ผิดแล้ว???

เคยรำคาญกันบ้างไหมเวลาเราพิมพ์ command ผิดแล้วมันไป resolve dns หรืออื่นๆที่ทำให้เรารอนานกว่ามันจะขึ้น prompt

C3825-FTN-OFFICE#xxx !<--- แกล้ง router โดยใส่ command ผิดไป
Translating "xxx"...domain server (255.255.255.255) !<--- ไป resolve dns ทำให้รอนาน

Translating "xxx"...domain server (255.255.255.255)

Translating "xxx"...domain server (255.255.255.255)
(255.255.255.255)% Unknown command or computer name, or unable to find computer address
C3825-FTN-OFFICE#conf t
Enter configuration commands, one per line. End with CNTL/Z.
C3825-FTN-OFFICE(config)#no ip domain lookup !<--- disable ไม่ให้มันไป resolve dns
C3825-FTN-OFFICE(config)#exit
C3825-FTN-OFFICE#xxx !<--- อีกรอบลองใส่ผิดอีก
Translating "xxx" ! <--- มันดันไป translate อะไรอีกล่ะเนี่ย

Translating "xxx"

Translating "xxx"
% Unknown command or computer name, or unable to find computer address
C3825-FTN-OFFICE#conf t
Enter configuration commands, one per line. End with CNTL/Z.
C3825-FTN-OFFICE(config)#line vty 0 4
C3825-FTN-OFFICE(config-line)#transport preferred none !<---- นี้เลยไป disable มันซ่ะเลย
C3825-FTN-OFFICE(config-line)#
C3825-FTN-OFFICE#xxx
^
% Invalid input detected at '^' marker. !<--- ค่อย make sense หน่อยว่าเราใส่ cmd ผิด

C3825-FTN-OFFICE#

[Cisco] การ Ping test ระบุ options

การ ping test เราควรกำหนด pattern ของ data ที่ส่งออกไปเพื่อ test การตอบสนอง bit 0,1 ซึ่ง data ค่า default 0xABCD และถ้าต้องการกำหนด size ของ packet
- กำหนด pattern ของ DATA
#ping ip 192.168.1.1 data FFFF repeat 100
and
#ping ip 192.168.1.1 data 0000 repeat 100
- กำหนด size ของ packet แต่ถ้าเกิน MTU จะ ถูก defrag
#ping ip 192.168.1.1 repeat 100 size 2000
- กำหนด size ของ packet และ set DF bit (dont' fragment bit)
#ping ip 192.18.1.1 repeat 100 size 2000 df-bit
- ระบุ source ip address
#ping ip 192.168.1.1 repeat 100 source 172.16.1.1
or
#ping ip 192.168.1.1 repeat 100 source Serial0/0 !-- ระบุ source ip เป็นของ serial0/0

Thursday, March 29, 2007

[Cisco] เขียน script tcl บน router

Cisco ก็สามารถเขียน script TCL ได้น่ะครับ ตัวอย่างต้องการ ping ไปหลายๆ ip

#tclsh ! เรียกใช้ tcl shell
foreach ip {
192.168.1.1
192.168.1.2
192.168.1.3
192.168.1.4
} { puts [ ping $ip source loopback0 repeat 100 ] }

! ก็จะเห็น Output
! ถ้าต้องการ ออกจาก tcl shell
#tclquit

เราสามารถเอาไป apply เพื่อใช้งาน script อื่นๆได้

[Cisco] เคยลอง ping test จำนวนมาก ไปที่ CAT65xx ตัวเอง แล้ว show proc cpu สูงมาก

วิธีแก้ไขให้ไปทำการ police icmp ที่ control-plane
แต่ผลของการ config จะไม่มีผลกับการ ping ผ่านตัว router ออกไป น่ะครับ จะมีผลเฉพาะกับการ ping มาที่ตัว router เท่านั้น
#conf t
ip access-list extended DDOS
permit icmp any any
class-map DDOS
match access-group name DDOS
policy-map CONTROL_PLANE
class DDOS
police 128000 conform-action transmit exceed-action drop violate-action drop
control-plane
service-policy input CONTROL_PLANE
end
#show policy-map control-plane
เท่านี้เรียบร้อยแล้ว ping มาที่ตัว router เท่าไหร่ก็ cpu ไม่สูง

[Cisco] ให้เก็บ config เป็น Archive log เวลา write mem ทุกครั้ง

เวลาเราต้องการดู log config เก่าๆมักจะมีปัญหา เพราะอาจจะไม่มีการเก็บไว วิธีนี้จะทำการเก็บ config ไว้ทุกครั้งที่ทำการ write mem ....
IOS version ใหม่ๆหน่อยน่ะครับ
เราจะทำ archive configไปเก็บไว้ใน flash ง่ายสุด

#mkdir flash:config-backup !<-- สร้าง directory ก่อนเพื่อเก็บ config
#conf t
archive
path flash:config-backup/config
maximum 14
write-memory
end
เสร็จแล้วต้องลองทดสอบดู
#wr
#show archive
There are currently 7 archive configurations saved.
The next archive file will be named flash:config-backup/config-7
Archive # Name
0
1 flash:config-backup/config-1
2 flash:config-backup/config-2
3 flash:config-backup/config-3
4 flash:config-backup/config-4
5 flash:config-backup/config-5
6 flash:config-backup/config-6 <- Most Recent
7
8
9
10
11
12
13
14
Ok จะเห็น config เก็บไว้

รู้จัก traceroute


คำสั่ง traceroute ในแต่ล่ะอุปกรณ์จะใช้ protocol ไม่เหมือนกันน่ะครับ บางครั้งเราอาจจะใช้ router trace ได้แต่ใช้ windows trace ไม่ได้อาจจะเป็นเพราะปลายทางมีการ block protocol บางประเภทเท่านั้น
Cisco ใช้ UDP ในคำสั่ง traceroute (udp port number 33434)
Windows ใช้ ICMP ในคำสั่ง tracert
Linux สามารถใช้ ICMP หรือ UDP ในคำสั่ง traceroute
การทำงาน(อ้างอิง Cisco ใช้ UDP port 33434)
1. ตัวอุปกรณ์ source จะทำการส่ง packet ออกไป 3 packet โดยชุดแรกก็จะ set TTL เป็น 1 เมื่อ router hop แรกโดยปกติเมื่อรับ packet ก็จะทำการลดค่า TTL ลง 1 ฉะนั้นเมื่อจะทำให้ TTL มีค่าเท่ากับ 0 ตัว router ก็จะส่ง ICMP message กลับไปบอก source ด้วย ICMP type time-exceed ทำให้ source รู้ว่า next hop แรกเป็น ip อะไร
2. Source จะทำการส่ง packet ออกครั้งที่ 2 แต่จะ set TTL เป็น 2 ซึ่งเมื่อ packet ผ่านแต่ละ router ก็จะมีการลดค่า TTL ทีล่ะ 1 ซึ่งเมื่อ router hop ที่ 2 ทำการลดค่า TTL ลงทำให้ TTL=0 router ก็จะส่ง ICMP type time-exceed กลับไปบอก source ก็เลยทำให้ source รู้ว่า hop ที่ 2 เป้น ip อะไร
3. Source จะทำการส่ง packet ออกไปแต่ล่ะครั้งก็จะเพิ่ม TTL ครั้งล่ะ 1 ทำให้ในแต่ล่ะ hop ตัว source รู้ว่าเป็น ip อะไรเพราะดูจาก ICMP time-exceed ที่ส่งกลับมา
4. เมื่อ packet ไปถึง destination ปรากฏว่า เมื่อ destination รับ packet เข้ามาเป็น udp port 33434 ซึ่ง destination ไม่ได้เปิด udp port 33434 นี้ ก็จะส่ง ICMP type port-unreachable กลับไปหา source ซึ่งจะทำให้ source รู้ว่า packet นี้กลับมาจาก destination จริงๆ