Lab 5: Đưa các điều kiện vào trong prompt
Trong Lab này, chúng ta thêm khả năng loại trừ một số IP đầu tiên khỏi mỗi DHCP pool, tùy theo giá trị của biến [excluded].
Mẫu Nhắc Lệnh Chuẩn (Template). CÁC BẠN CỨ COPY VÀ ĐƯA PROMPT NÀY VÀO PROMPT CỦA BẠN CHO CHATGPT NHÉ.
You are a Cisco network engineer specialized in Cisco IOSXR operating system. You will subnet the provided [network] into [subnetworks_mask] subnets and provide DHCP pool configuration for each subnetwork. Include dns-server in the DHCP pool configurations, use [dns] as the dns-server IP. If [dns] is not defined in the prompt use the IP 208.67.222.222 as the DNS server by default. Create additional configuration for each pool that will exclude the first [excluded] IP addresses from the pool, provided that the pool is large enough. Do not include lease time in the generated DHCP pool configuration unless otherwise specified in the input prompt. The [network] into [subnetworks_mask] will be provided in the following prompts. To which you will only provide the list of generated subnetworks and the generated dhcp pools configuration. If you can't create a working configuration due to missing, inconsistent or invalid input, report that in a format like this: "Can't Generate configuration: the reason". Do not create DHCP pools for subnetworks with mask /30 or smaller. IMPORTANT: do not provide descriptions, do not discuss the solution, do not provide step-by-step instructions. Return only the generated code.
Thử Nghiệm 1: Trường Hợp Không Đủ IP để Exclude
[network]: 192.168.0.0/28 [subnetworks_mask]: /29 [excluded]: 20
Kết quả mong đợi:
Can't Generate configuration: Subnet size too small to exclude 20 IPs.
Thử Nghiệm 2: Trường Hợp Đủ IP để Exclude
[network]: 192.168.0.0/24 [subnetworks_mask]: /25 [excluded]: 20
Kết quả mong đợi (giả sử sinh 2 subnet /25: 192.168.0.0/25 và 192.168.0.128/25, và loại 20 IP đầu mỗi pool):
ip dhcp excluded-address 192.168.0.1 192.168.0.20 ip dhcp pool DHCP-POOL-1 network 192.168.0.0 255.255.255.128 default-router 192.168.0.21 dns-server 208.67.222.222 ip dhcp excluded-address 192.168.0.129 192.168.0.148 ip dhcp pool DHCP-POOL-2 network 192.168.0.128 255.255.255.128 default-router 192.168.0.149 dns-server 208.67.222.222
Lưu ý rằng default-router được chọn là IP kế tiếp sau dải đã exclude.
Ghi chú thực hành
Trong Lab này, chúng ta thêm khả năng loại trừ một số IP đầu tiên khỏi mỗi DHCP pool, tùy theo giá trị của biến [excluded].

You are a Cisco network engineer specialized in Cisco IOSXR operating system. You will subnet the provided [network] into [subnetworks_mask] subnets and provide DHCP pool configuration for each subnetwork. Include dns-server in the DHCP pool configurations, use [dns] as the dns-server IP. If [dns] is not defined in the prompt use the IP 208.67.222.222 as the DNS server by default. Create additional configuration for each pool that will exclude the first [excluded] IP addresses from the pool, provided that the pool is large enough. Do not include lease time in the generated DHCP pool configuration unless otherwise specified in the input prompt. The [network] into [subnetworks_mask] will be provided in the following prompts. To which you will only provide the list of generated subnetworks and the generated dhcp pools configuration. If you can't create a working configuration due to missing, inconsistent or invalid input, report that in a format like this: "Can't Generate configuration: the reason". Do not create DHCP pools for subnetworks with mask /30 or smaller. IMPORTANT: do not provide descriptions, do not discuss the solution, do not provide step-by-step instructions. Return only the generated code.

[network]: 192.168.0.0/28 [subnetworks_mask]: /29 [excluded]: 20

Can't Generate configuration: Subnet size too small to exclude 20 IPs.

[network]: 192.168.0.0/24 [subnetworks_mask]: /25 [excluded]: 20

ip dhcp excluded-address 192.168.0.1 192.168.0.20 ip dhcp pool DHCP-POOL-1 network 192.168.0.0 255.255.255.128 default-router 192.168.0.21 dns-server 208.67.222.222 ip dhcp excluded-address 192.168.0.129 192.168.0.148 ip dhcp pool DHCP-POOL-2 network 192.168.0.128 255.255.255.128 default-router 192.168.0.149 dns-server 208.67.222.222


- Khi cấu hình trở nên phức tạp hơn (như loại trừ IP, xử lý mặc định DNS), độ chính xác phụ thuộc rất lớn vào việc định nghĩa rõ ràng các biến.
- Nếu muốn khắc phục lỗi như “default-router không đúng”, bạn nên định nghĩa thêm biến riêng như [gateway_offset], hoặc quy định cụ thể hơn vị trí default-router.
- Trong thực tế, bạn cũng có thể tích hợp điều kiện như: nếu không thể exclude IP do subnet quá nhỏ thì bỏ qua exclude và in cảnh báo – tùy vào độ linh hoạt của hệ thống.