在子网中安装 Linux 时缺少来自 dhcp 的默认路由

在子网中安装 Linux 时缺少来自 dhcp 的默认路由

我尝试在 PC 上安装 Debian,但没有获得默认路由,也无法访问互联网。它显示:

网络自动配置成功。但是,未设置默认路由:系统不知道如何与 Internet 上的主机通信。

ip route show
192.168.147.0/24 dev esp4n0 src 192.168.147.50

不确定哪里出了问题,因为我的其他系统在我的子网中运行正常。所有系统都有默认路由。我尝试自己设置默认路由,但这也没有用。

ip route add default via 192.168.147.1
ip route show
default via 192.168.147.1 dev enp4s0 src 192.168.147.50
192.168.147.0/24 dev enp4s0 src 192.168.147.50 

我有一个 Fritz.Box (192.168.178.1) 作为互联网连接的服务器 (dhcp、dns 等)。Fritz.Box 会在eth1(192.168.178.20)。我在eth0通过 isc-dhcp-server (192.168.147.0/24)。Fritz.Box 经常断开连接,这样我就不必一直担心网络丢失。

这是我的服务器的配置...

/etc/dhcp/dhcpd.conf

# 
# Sample configuration file for ISC dhcpd for Debian
# /etc/dhcp/dhcpd.conf
#

option domain-name "heimat.lokal";
option domain-name-servers 192.168.178.1;
option routers 192.168.147.1, 192.168.178.1;

# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages ('none', since DHCP v2 didn't
# have support for DDNS.)
ddns-update-style none;

# DHCP-Server sollten das folgende Statement im globalen Bereich ihrer Konfiguration aufweisen, wenn der Administrator keine falsch konfigurierten "Rogue"-DHCP-Server im eigenen Netzwerk dulden will (also eigentlich immer):
authoritative;

default-lease-time 600;
max-lease-time 7200;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

subnet 192.168.147.0 netmask 255.255.255.0 {
    #interface eth0;
    range 192.168.147.50 192.168.147.60;
    #option routers 192.168.178.1, 192.168.147.1;
}

/etc/default/isc-dhcp 服务器

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

/etc/network/interfaces.d/gigabyte_mb_dual_gigabit_lan

auto    eth0=lan0
auto    eth1=lan1

# 01:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 0c)
iface   eth0    inet    manual
    pre-up ifconfig $IFACE up
    post-down ifconfig $IFACE 0.0.0.0 down

# 02:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 0c)
iface   eth1    inet    manual
    pre-up ifconfig $IFACE up
    post-down ifconfig $IFACE 0.0.0.0 down


iface   lan1    inet    dhcp

iface   lan0    inet    static
    address 192.168.147.1
    dns-nameservers 192.168.178.1

/etc/sysctl.d/99-sysctl.conf

net.ipv4.ip_forward=1

需要说明的是:我的子网中运行着多个系统,它们通过我的 isc-dhcp-server/gateway 组合完美运行。也没有阻止防火墙。我只是无法通过 debian net-install 映像在此子网上安装新系统。

答案1

我找到了一个解决方案。我不用使用,而是ip route add default via 192.168.147.1输入route add default gw 192.168.147.1。现在我可以安装系统了。

相关内容