Cisco packet tracer คำสั่งตั้งค่าแต่ละแบบ

vlan, lacp, native vlan, VTP, OSPF, BGP, PAT, Router on Stick

Piravit Chenpittaya
5 min readAug 31, 2021

เมื่อปีที่แล้วได้เรียนวิชา 240–206 Intro to computer Network ก็ได้มีการบ้านเกี่ยวกับการแก้จัดการ network บน cisco packet tracer โดยให้ศึกษาเอง แล้วก็รู้สึกว่าจะต้องได้ใช้อีกแน่ๆ ดังนั้นผมจึงเอาข้อมูลในไฟล์เก่าๆที่เคยจดไว้มาฝากไว้ซะหน่อยเดียวทำไฟล์หาย 555

note: ความหมายตัวอักษรย่อ
S = Switch, R = Router

Trunk Port

เป็น Port ที่สามารถมี Traffic ของหลายๆ VLAN วิ่งผ่านได้
ตัวอย่างในการตั้งค่า Port ของ Switch ให้เป็น Trunk Port เช่น
– Port ที่ทําหน้าที่เชื่อมต่อไปยัง Switch ตัวอื่น ๆ เช่น Uplink Port
– Port ที่ทําหน้าที่เชื่อม ไปยัง Routerตัวที่ทําหน้าที่ Route Traffic ระหว่าง VLAN

Access Port

Port ที่ถูกตั้งค่าเป็น Access Port จะมี traffic ของ VLAN เพียง VLAN เดียววิ่งผ่านได้ ตัวอย่างในการตั้งค่า Port ให้เป็น Access Port เช่น
– Port ที่เชื่อมต่อระหว่าง Switch และ Client
– Port ที่เชื่อมต่อระหว่าง Switch และ Server
– Port ที่เชื่อมต่อระหว่าง Switch และ Router (มีข้อแม้ว่า Router ที่เชื่อมต่อนั้น จะต้องไม่ใช่ Router ที่ทําหน้าที่ในการ Route Traffic ระหว่าง VLAN)หากอ่านแค่ข้อความด้านบน อาจจะไม่เข้าใจมากนัก และ คงไม่เห็นภาพของคำว่า Trunk Port ที่ชัดเจนได้ ลองมาดูรายละเอียดเพิ่มเติมกันนะครับTrunk Port และ Access Port

:vlan

A Virtual LAN (VLAN) is simply a logical LAN, just as its name suggests. VLANs have similar characteristics with those of physical LANs, only that with VLANs, you can logically group hosts even if they are physically located on separate LAN segments.

2 Vlan cisco packet tracer
2 VLAN
S1(config)#vlan 10S1(config-vlan)#exitS1(config)#interface fastEthernet 0/1S1(config-if)#switchport access vlan 10

so on… วนไปเรื่อยๆตามต้องการ

:set group lacp

Link Aggregation Control Protocol is one element of an IEEE specification (802.3ad) that provides guidance on the practice of link aggregation for data connections.

Switch>enableSwitch#configure terminalEnter configuration commands, one per line. End with CNTL/Z.Switch(config)#host switch0vlan 99exswitch0(config)#interface range gi0/1–2switch0(config-if-range)#channel-group 1 mode activeswitch0(config-if-range)#channel-protocol lacp

:native vlan

native vlan(untagged vlan) เป็น vlan ที่มีความพิเศษตรงที่ Ethernet Frame ใดที่ถูก forword ออกมาจาก vlan ที่เป็น native vlan เข้าไปยัง port ที่ทำเป็น trunkไว้จะไม่ต้องทำการ tag vlan id เข้าไป ซึ่งในขณะที่ vlan อื่นๆ ที่เราไม่ได้สั่งให้เป็น native vlan จำเป็นจะต้องสั่งให้ tag vlan id เข้าไปด้วยเสมอ

https://mihthai.blogspot.com/2018/02/native-vlan.html

S1(config)#int po{number}S1(config-if)#switchport trunk native vlan 99S1(config-if)#switchport mode trunkint vlan 99ip address … …no shut

:VTP

manage all configured VLANs across the network.

S1(config)#vtp mode server // mode clientS1(config)#vtp domain exampleS1(config)#vtp password vinitaS1(config)#vtp version 2

:Router on Stick

(vitual interface)

Router(config)#interface fastEthernet 0/0.10Router(config-subif)#encapsulation dot1Q 10 //(vlan 10)Router(config-subif)#ip address 10.0.0.1 255.0.0.0Router(config-subif)#exitRouter(config)#interface fastEthernet 0/0.20Router(config-subif)#encapsulation dot1Q 20 //(vlan 20)Router(config-subif)#ip address 20.0.0.1 255.0.0.0Router(config-subif)#exit

:OSPF

ที่เป็นมาตรฐานกลาง (RFC 2328) และมีข้อดีคือที่เป็นธรรมชาติของ routing protocol แบบ link-state ก็คือ จะไม่มีโอกาสเกิด routing loop ขึ้นในระบบเครือข่าย เนื่องจากมันจะสามารถมองเห็น topology ของระบบเครือข่ายได้ ก่อนที่จะทำการคัดเลือกเส้นทางที่ดีที่สุดที่จะใช้ไปยังแต่ละปลายทา

router ospf {number}router-id {ip}network …

:BGP

BGP (Border Gateway Protocol) เป็นโปรโตคอลเลือกเส้นทางประเภท Exterior Gateway Routing ที่ใช้เพื่อการเชื่อมต่อ Router และเครือข่ายที่อยู่ต่าง Domain กันบน Internet ที่ใช้สำหรับการหาเส้นทางภายในระบบออโตโนมัส

WAN1 router configuration

A simple BGP peering with ISP1 router is configured in the WAN1 router.

interface Serial0/0/0
ip address 156.12.1.6 255.255.255.252
!
router bgp 65000
bgp log-neighbor-changes
no synchronization
neighbor 156.12.1.5 remote-as 10000

ISP1 router configuration

Several loopback interfaces are configured in ISP1 router to simulate connected networks whose are advertised to WAN1 router through the BGP peering.

interface Loopback0
ip address 156.100.1.1 255.255.255.0
!
interface Loopback1
ip address 156.100.2.1 255.255.255.0
!
interface Loopback2
ip address 156.100.4.1 255.255.254.0
!
interface Serial0/0/0
ip address 156.12.1.5 255.255.255.252
clock rate 500000
!
router bgp 10000
bgp log-neighbor-changes
no synchronization
neighbor 156.12.1.6 remote-as 65000
network 156.100.4.0 mask 255.255.254.0
network 156.100.2.0 mask 255.255.255.0
network 156.100.1.0 mask 255.255.255.0

!

:ip classless

เพื่อให้routerคำนึงแค่ prefix length ในการเลือกเส้นทาง ไม่ต้องพิจารณาว่า IP ปลายทางอยู่ในเครือข่าย หรือกลุ่มไอพี(Class) บนเส้นทางดังกล่าวหรือไม่

สมมติ ปกติ ส่งไป 102.0.0.20 routerหาที่คล้ายกันคือ 102.0.0.0/30 แต่ดันไม่มี .20 ในเครือข่ายจึงต้อง drop ทึ้ง การใช้ classless จะทำให้ไม่สนใจแล้วส่งไปแม้ว่าไม่มี

http://www.ranet.co.th/articles/ART-CFG-003-IPclassless.pdf

> ip route {self_router_ip_host} {subnet_mask} Null0— -ip route 102.0.0.0 255.255.0.0 Null0

:OSPF V3

OSPFv3 คือ OSPF Routing Versionใหม่ที่สามารถทำการ Routing ได้ทั้ง IPv4 และ IPv6

http://www.ninehua.com/index.php/story/menu-nw/187-ipv6ospfv3

R1(config)# ipv6 unicast-routingR1(config)# ipv6 router ospf 1 // Create an OSPFv3 processR1(config-rtr)# router-id 1.1.1.1R1(config-rtr)# exit
R1(config)# int fa0/0R1(config-if)# ipv6 ospf 1 area 0//Add router interfaces to the OSPFv3 process just createdR1(config-if)#R1(config-if)# int serial 0/0/0R1(config-if)# ipv6 ospf 1 area 0

:NAT

routers or firewalls translate one private IP address to a single public IP address.

:PAT

a single public IP address is used for all internal private IP addresses

PAT allows you to support many hosts with only few public IP addresses. It works by creating dynamic NAT mapping

‘Overloading’ means that the single public IP assigned to your router can be used by multiple internal hosts concurrently.

(tcp port static)

Router (config)# ip nat inside source static tcp {local ip} {port} {global ip} {port}

-Router(config)#ip nat inside source static tcp 192.168.1.3 80 192.168.2.1 80

(full nat Static)

Router (config)# ip nat inside source static {local ip} {global ip}

(dynamic)

Router(config)#ip nat inside source list {1} interface {Gi0/0/1} overload

เครดิต trunk, access port

https://www.itandaman.com/236.html

--

--

Piravit Chenpittaya
Piravit Chenpittaya

Written by Piravit Chenpittaya

call me karn | Computer of Engineering : PSU | IG: karn.svg | git: https://github.com/karnzx /

No responses yet