在子網路中安裝 Linux 時缺少 dhcp 的預設路由

在子網路中安裝 Linux 時缺少 dhcp 的預設路由

我嘗試在 PC 上安裝 Debian,但沒有獲得預設路由並且無法存取互聯網。它說:

網路自動配置成功。然而,沒有設定預設路由:系統不知道如何與網際網路上的主機通訊。

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 將靜態 IP 傳送到我的伺服器系統乙太網路1(192.168.178.20)。我運行一個子網乙太網路0透過 isc-dhcp-伺服器 (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。現在我可以安裝系統了。

相關內容