
Virtual Routing and Forwarding หรือ VRF เป็นเทคโนโลยีที่ช่วยใช้สามารถมี Routing instant บน Router 1 ตัวได้ ถ้าเข้าใจได้ง่ายๆ ยกตัวอย่างเปรียบเทียบกับ VLAN โดย Default Switch จะมี VLAN1 เดียว และเมื่อเราต้องการจำลอง Switch หลายๆ ตัวแยกกัน บน Switch ตัวเดียว เพื่อแยก Broadcast domain หรือต้องการแยก trafic เสมือนกับการมี switch 2 ตัว วิธีการนี้ เรียกกว่าการสร้าง VLAN และ ใน Router ก็มีฟังชันก์การทำงานคล้ายๆ การสร้าง VLAN เช่นกัน นั่นคือ VRF โดยปกติ เราจะใช้ VRF default เราจะใช้ VRF ในกรณีที่ต้องการแยก Routing ออกจากกัน เสมือนกับมี Router สองตัวที่ทำงานแยกกัน เช่น ISP ให้บริการกับลูกค้าสองเจ้า ซึ่งเป็นคู่แข่งกัน ซึ่งทั่งสองเจ้าไม่ต้องการให้เห็น Routing ของกันและกัน แต่ ISP ต้องการใช้ Router เพียงตัวเดียว การใช้ VRF ก็จะช่วยให้สามารถแก้ปัญหาดังกล่าวนี้ได้ และช่วยลดต้นทุน ให้กับฝั่งผู้ให้บริการอีกด้วย และการใช้ VRF, Router จะมองว่ามี Router สองตัว แยกออกจากกัน (ในกรณีที่ใช้ 2 VRF) ทำให้สามารถใช้ IP ชุดเดียวกันได้

การคอนฟิก
1. สร้าง VRF Instant
R1(config)#ip vrf Company-A
R1(config-vrf)#
R1(config-vrf)#exit
R1(config)#ip vrf Company-B
R1(config-vrf)#exit
Verify VRF ที่สร้าง โดยใช้คำสั่ง show ip vrf
R1#show ip vrf
Name Default RD Interfaces
Company-A <not set>
Company-B <not set>
2. Assign VRF to Interface
ในตัวอย่างนี้จะกำหนด vrf ไปที่ Router sub interface โดยใช้ VLAN 10 และ 20
R1(config)#interface f0/0.10
R1(config-if)#ip vrf forwarding Company-A
R1(config-if)#encapsulation dot1q 10
R1(config-if)#ip address 10.10.10.1 255.255.255.0
R1(config-if)#exit
R1(config)#interface f0/0.20
R1(config-if)#ip vrf forwarding Company-B
R1(config-if)#encapsulation dot1q 20
R1(config-if)#ip address 10.10.10.1 255.255.255.0
Verify configuration
R1#show ip vrf
Name Default RD Interfaces
Company-A <not set> Fa0/0.10
Company-B <not set> Fa0/0.20
ทดลอง Ping จาก Client Company-A
Host-A>ping 10.10.10.1 Pinging 10.10.10.1 with 32 bytes of data: Reply from 10.10.10.1: bytes=32 time=1ms TTL=255 Reply from 10.10.10.1: bytes=32 time=1ms TTL=255 Reply from 10.10.10.1: bytes=32 time=2ms TTL=255 Reply from 10.10.10.1: bytes=32 time=1ms TTL=255
ทดลอง Ping จาก Company-B
Host-B>ping 10.10.10.1
Pinging 10.10.10.1 with 32 bytes of data:
Reply from 10.10.10.1: bytes=32 time=1ms TTL=255
Reply from 10.10.10.1: bytes=32 time=2ms TTL=255
Reply from 10.10.10.1: bytes=32 time=2ms TTL=255
Reply from 10.10.10.1: bytes=32 time=1ms TTL=255
ทดลอง Ping จาก Router ไปยัง PC ที่ Company A และ B
R1#ping vrf Company-A 10.10.10.50
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.10.10.50, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms
MBG001#ping vrf Company-B 10.10.10.50
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.10.10.50, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
จะเห็นได้ว่าการใช้ VRF จะทำให้ Routing บน Router นั้นถูกแยกออกจากกัน ทำให้ Routing ทั้งสองชุดไม่มาปะปนกัน และยังสามารถใช้ชุดไอพีเดียวกันกับ Network 2 ชุดได้อีกด้วย