如何为一台带有 dhcp 的电脑提供默认网关,而其他电脑则使用静态 IP 和静态默认网关

网络工程 dhcp 局域网
2022-02-23 18:46:55

在此处输入图像描述

我有这个拓扑,其中 PC0、Server0 和 PC4 使用静态 ip 和静态默认网关,但是一台 pc 是请求 DHCP,所以我必须为他使用 DHCP ip 地址,其余的使用静态 ip,现在问题是如何给他 default-dateway,这样他就可以 ping PC0 和 Server0,反之亦然。

配置:

Router
fa0/0 = 192.168.10.1/24
fa0/1 = 192.168.11.1/24

PC0(Static)
IP              = 192.168.10.123/24
default-gateway = 192.168.10.1

Server0(Static)
IP              = 192.168.10.111/24
default-gateway = 192.168.10.1

PC4(Static)
IP              = 192.168.11.123/24
default-gateway = 192.168.11.1

Router
DHCP pool nf0/0
Network 192.168.11.0 255.255.255.0

PC-PT(DHCP)
IP               = 192.168.11.2/24
Default-gateway  = Doesnt exist because i don't know how to config it
2个回答

欢迎来到网络工程!您可以在路由器上为 request-PC 配置 DHCP。默认网关与 PC4 相同:192.168.11.1。不同之处在于 Request-PC 从 DHCP 获取网关地址,而 PC4 是静态配置的。

您的配置中缺少一些东西

  1. 您需要从要分配给主机的地址池中排除默认网关

  2. 在您的配置中,您需要设置要分配给每个地址池的默认网关

您将以下配置添加到路由器。


! Move to Privileged mode
enable

! Global configuration mode
configure terminal

! Exclude the ip address of the default gateway
! from the pool of network
ip dhcp excluded-address 192.168.11.1

ip dhcp pool networkf0/1
! Set the default gateway for the hosts
! which will be using this pool of address
default-router 192.168.11.1

完成后,您需要禁用并重新启用 PC“请求 DHCP”下的 DHCP 选项。

并做了!