我已经在 Ubuntu 服务器 20.04 上设置了 isc-dhcp-server。isc-dhcp-server 启动正常。
为了设置我的本地网络,我使用了:
- 一台 PC 来托管 isc-dhcp-server
- 一台 PC 作为客户端
- 用于连接服务器和客户端的交换机
以下是 isc-dhcp-server 状态:
sudo systemctl restart isc-dhcp-server
sudo systemctl status isc-dhcp-server.service
isc-dhcp-server.service - ISC DHCP IPv4 server
Loaded: loaded (/lib/systemd/system/isc-dhcp-server.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2021-06-10 21:44:03 GMT; 3s ago
Docs: man:dhcpd(8)
Main PID: 6526 (dhcpd)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/isc-dhcp-server.service
└─6526 dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dhcpd.pid -cf /etc/dhcp/dhcpd.conf br-6bc01dce843b
juin 10 21:44:03 tt-TECRA-R700 dhcpd[6526]: PID file: /run/dhcp-server/dhcpd.pid
juin 10 21:44:03 tt-TECRA-R700 dhcpd[6526]: Wrote 0 leases to leases file.
juin 10 21:44:03 tt-TECRA-R700 sh[6526]: Wrote 0 leases to leases file.
juin 10 21:44:04 tt-TECRA-R700 dhcpd[6526]: Listening on LPF/br-6bc01dce843b/02:42:f0:1e:4f:21/172.18.0.0/16
juin 10 21:44:04 tt-TECRA-R700 sh[6526]: Listening on LPF/br-6bc01dce843b/02:42:f0:1e:4f:21/172.18.0.0/16
juin 10 21:44:04 tt-TECRA-R700 sh[6526]: Sending on LPF/br-6bc01dce843b/02:42:f0:1e:4f:21/172.18.0.0/16
juin 10 21:44:04 tt-TECRA-R700 sh[6526]: Sending on Socket/fallback/fallback-net
juin 10 21:44:04 tt-TECRA-R700 dhcpd[6526]: Sending on LPF/br-6bc01dce843b/02:42:f0:1e:4f:21/172.18.0.0/16
juin 10 21:44:04 tt-TECRA-R700 dhcpd[6526]: Sending on Socket/fallback/fallback-net
juin 10 21:44:04 tt-TECRA-R700 dhcpd[6526]: Server starting service.
但是,当我插入网线将服务器连接到交换机时,出现以下消息:
network failed - Connection activation failed
我尝试将客户端连接到交换机,以便它可以从 dhcp 服务器获取地址,但客户端根本没有获取任何地址。
$ ifconfig
br-6bc01dce843b: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.18.0.1 netmask 255.255.0.0 broadcast 172.18.255.255
ether 02:42:f0:1e:4f:21 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:0e:7d:a0:2a txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp0s25: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether 00:23:18:41:b2:fb txqueuelen 1000 (Ethernet)
RX packets 1538 bytes 272584 (272.5 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8126 bytes 1449096 (1.4 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 20 memory 0xd4700000-d4720000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Boucle locale)
RX packets 465692 bytes 44635267 (44.6 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 465692 bytes 44635267 (44.6 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp2s0b1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.101 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::de66:bfea:9ee9:d266 prefixlen 64 scopeid 0x20<link>
ether 4c:ed:de:54:ae:7d txqueuelen 1000 (Ethernet)
RX packets 3915334 bytes 3388537159 (3.3 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3286057 bytes 606308993 (606.3 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
$ sudo gedit /etc/default/isc-dhcp-server
#INTERFACESv4="wlp2s0b1"
INTERFACESv4="br-6bc01dce843b"
INTERFACESv6=""
sudo gedit /etc/dhcp/dhcpd.conf
# dhcpd.conf
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;
default-lease-time 600;
max-lease-time 7200;
ddns-update-style none;
authoritative;
subnet 172.18.0.0 netmask 255.255.0.0
{
range 172.18.0.10 172.18.0.50;
# option routers 172.18.0.1;
option subnet-mask 255.255.0.0;
# option broadcast-address 172.18.255.255;
}