为学校俱乐部网络设置 LAN 网关 - “enp3s0 没有子网声明”

为学校俱乐部网络设置 LAN 网关 - “enp3s0 没有子网声明”

我是一名计算机老师,我正在尝试为课后计算机俱乐部建立一个可以访问互联网的“沙盒”网络。

我有一台旧 PC(安装有 Debian 11),它有 2 个以太网接口,一个接口连接到标准学校网络。这用于将互联网流量传输到第二个接口。第二个接口将为小型教室网络提供 dhcp 和互联网。笔记本电脑和 Raspberry Pi 等设备将连接到此交换机,有时还会连接到 WiFi 接入点。

以下是物理设置。enp2s0 连接到学校,enp3s0 连接到我的计算网络。

ser@computingClubBridge:~$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 34:64:a9:24:01:55 brd ff:ff:ff:ff:ff:ff
    inet 10.202.248.250/21 brd 10.202.255.255 scope global dynamic enp2s0
       valid_lft 621249sec preferred_lft 621249sec
    inet 10.202.248.240/21 brd 10.202.255.255 scope global secondary enp2s0
       valid_lft forever preferred_lft forever
    inet6 fe80::3664:a9ff:fe24:155/64 scope link 
       valid_lft forever preferred_lft forever
3: enp3s0: <BROADCAST,MULTICAST,DYNAMIC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:e0:4c:69:1f:cd brd ff:ff:ff:ff:ff:ff
    inet 169.254.151.221/16 brd 169.254.255.255 scope global enp3s0
       valid_lft forever preferred_lft forever
    inet6 fe80::2e0:4cff:fe69:1fcd/64 scope link 
       valid_lft forever preferred_lft forever

我一直在关注这个教程,但是它的部分内容已经过时,因为它涉及 dhcp3,所以我用 isc-dhcp-server 替换了它。

https://www.debuntu.org/how-to-set-up-a-lan-gateway-with-dhcp-dynamic-dns-and-iptables-on-debian-etch-page-3-dhcp-server/

/etc/default/isc-dhcp-server 当前为:

Defaults for isc-dhcp-server (sourced by /etc/init.d/isc-dhcp-server)

# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
DHCPDv4_CONF=/etc/dhcp/dhcpd.conf
#DHCPDv6_CONF=/etc/dhcp/dhcpd6.conf

# Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
#DHCPDv4_PID=/var/run/dhcpd.pid
#DHCPDv6_PID=/var/run/dhcpd6.pid

# Additional options to start dhcpd with.
#       Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
#OPTIONS=""

# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
#       Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACESv4="enp3s0"
INTERFACESv6=""

为了尝试使子网正常工作,我将教程中的 /etc/dhcp 中的 dhcp.conf 文件简​​化为:

subnet 192.168.2.0 netmask 255.255.255.0 {
  range 192.168.2.5 192.168.2.200;
  option routers  router.lan.computing.local;
}

但是重新启动 isc-dhcp-server 不起作用。Syslog 显示以下消息。

Nov 17 11:54:45 computingClubBridge dhcpd[8828]: No subnet declaration for enp3s0 (169.254.151.221).
Nov 17 11:54:45 computingClubBridge dhcpd[8828]: ** Ignoring requests on enp3s0.  If this is not what
Nov 17 11:54:45 computingClubBridge dhcpd[8828]:    you want, please write a subnet declaration
Nov 17 11:54:45 computingClubBridge dhcpd[8828]:    in your dhcpd.conf file for the network segment
Nov 17 11:54:45 computingClubBridge dhcpd[8828]:    to which interface enp3s0 is attached. **
Nov 17 11:54:45 computingClubBridge dhcpd[8828]: 
Nov 17 11:54:45 computingClubBridge dhcpd[8828]: 
Nov 17 11:54:45 computingClubBridge dhcpd[8828]: Not configured to listen on any interfaces!
Nov 17 11:54:45 computingClubBridge dhcpd[8828]: 
Nov 17 11:54:45 computingClubBridge dhcpd[8828]: If you think you have received this message due to a bug rather
Nov 17 11:54:45 computingClubBridge dhcpd[8828]: than a configuration issue please read the section on submitting
Nov 17 11:54:45 computingClubBridge dhcpd[8828]: bugs on either our web page at www.isc.org or in the README file
Nov 17 11:54:45 computingClubBridge dhcpd[8828]: before submitting a bug.  These pages explain the proper
Nov 17 11:54:45 computingClubBridge dhcpd[8828]: process and the information we find helpful for debugging.
Nov 17 11:54:45 computingClubBridge dhcpd[8828]: 
Nov 17 11:54:45 computingClubBridge dhcpd[8828]: exiting.
Nov 17 11:54:47 computingClubBridge isc-dhcp-server[8812]: Starting ISC DHCPv4 server: dhcpdcheck syslog for diagnostics. ...
Nov 17 11:54:47 computingClubBridge isc-dhcp-server[8833]:  failed!
Nov 17 11:54:47 computingClubBridge isc-dhcp-server[8834]:  failed!
Nov 17 11:54:47 computingClubBridge systemd[1]: isc-dhcp-server.service: Control process exited, code=exited, status=1/FAILURE
Nov 17 11:54:47 computingClubBridge systemd[1]: isc-dhcp-server.service: Failed with result 'exit-code'.
Nov 17 11:54:47 computingClubBridge systemd[1]: Failed to start LSB: DHCP server.

我不知道有什么方法可以尝试进一步取得进展,据我所知,我已经使用示例 isc-dhcp-server 配置为网络接口声明了一个子网,但是 DHCP 不想使用它?

答案1

您显然已将 enp3s0 配置为自动配置,因此它尝试通过 DHCP 获取 IP 地址但失败了;这就是它自动分配 169.254.151.221/16 地址的原因。为了将此接口用作 DHCP 服务器,您首先需要在其上配置一个静态 IP 地址,并且该地址必须在您想要从中提供的 IP 地址范围内。即,如果您希望学生的计算机获取 192.168.2.0-255 范围内的 IP 地址,则必须为 enp3s0 配置一个此范围内的地址,例如 192.168.2.1/24。静态 IP 地址。

相关内容