如何添加带有尾随零的默认网关?

如何添加带有尾随零的默认网关?

在办公室,我想将我的 Ubuntu 18.04 笔记本电脑连接到以太网。我所有的同事都在使用 Windows 10 笔记本电脑,没有任何问题,我是唯一一个拥有 Ubuntu 笔记本电脑的人。

DHCP 服务器返回默认网关 192.168.2.0。但我的笔记本电脑不接受此网关。当我尝试添加默认网关时,我收到以下错误消息:

sudo route add default gw 192.168.2.0 dev eth0
SIOCADDRT: Network is unreachable

dhclient 的输出:

sudo dhclient -v eth0
Internet Systems Consortium DHCP Client 4.3.5
Copyright 2004-2016 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/eth0/28:f1:0e:0a:de:34
Sending on   LPF/eth0/28:f1:0e:0a:de:34
Sending on   Socket/fallback
DHCPREQUEST of 192.168.2.169 on eth0 to 255.255.255.255 port 67 (xid=0x6bb234ba)
DHCPACK of 192.168.2.169 from 192.168.2.0
RTNETLINK answers: File exists
bound to 192.168.2.169 -- renewal in 14325 seconds.

Wireshark 捕获 dhcp ACK 数据包:

Frame 6: 342 bytes on wire (2736 bits), 342 bytes captured (2736 bits) on interface 0
Ethernet II, Src: Lancom_2a:35:48 (xx:xx:xx:xx:xx:xx), Dst: Broadcast (ff:ff:ff:ff:ff:ff)
Internet Protocol Version 4, Src: 192.168.2.0, Dst: 255.255.255.255
User Datagram Protocol, Src Port: 67, Dst Port: 68
Bootstrap Protocol (ACK)
    Message type: Boot Reply (2)
    Hardware type: Ethernet (0x01)
    Hardware address length: 6
    Hops: 0
    Transaction ID: 0x4b1a125c
    Seconds elapsed: 0
    Bootp flags: 0x0000 (Unicast)
        0... .... .... .... = Broadcast flag: Unicast
        .000 0000 0000 0000 = Reserved flags: 0x0000
    Client IP address: 0.0.0.0
    Your (client) IP address: 192.168.2.169
    Next server IP address: 192.168.2.0
    Relay agent IP address: 0.0.0.0
    Client MAC address: Dell_0a:de:34 (28:f1:0e:0a:de:34)
    Client hardware address padding: 00000000000000000000
    Server host name not given
    Boot file name not given
    Magic cookie: DHCP
    Option: (53) DHCP Message Type (ACK)
        Length: 1
        DHCP: ACK (5)
    Option: (54) DHCP Server Identifier
        Length: 4
        DHCP Server Identifier: 192.168.2.0
    Option: (1) Subnet Mask
        Length: 4
        Subnet Mask: 255.255.255.0
    Option: (3) Router
        Length: 4
        Router: 192.168.2.0
    Option: (6) Domain Name Server
        Length: 4
        Domain Name Server: 192.168.2.0
    Option: (15) Domain Name
        Length: 6
        Domain Name: intern
    Option: (28) Broadcast Address
        Length: 4
        Broadcast Address: 192.168.2.255
    Option: (51) IP Address Lease Time
        Length: 4
        IP Address Lease Time: (30000s) 8 hours, 20 minutes
    Option: (255) End
        Option End: 255
    Padding: 000000000000000000000000

ipconfig /all连接到同一网络的 Windows 笔记本电脑上的命令输出:

   Connection-specific DNS Suffix  . : intern
   Description . . . . . . . . . . . : Intel(R) Ethernet Connection (2) I219-LM
   Physical Address. . . . . . . . . : xx-xx-xx-xx-xx-xx
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   IPv4 Address. . . . . . . . . . . : 192.168.2.9(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : Freitag, 30. August 2019 09:15:13
   Lease Expires . . . . . . . . . . : Freitag, 30. August 2019 23:59:39
   Default Gateway . . . . . . . . . : 192.168.2.0
   DHCP Server . . . . . . . . . . . : 192.168.2.0
   DNS Servers . . . . . . . . . . . : 192.168.2.0
   NetBIOS over Tcpip. . . . . . . . : Enabled

答案1

如果这是 /24 网络,则无法将 192.168.2.0 添加为 GW。在 /24 中,这是网络地址。广播位于 192.168.2.255。如果路由器使用此 IP 作为 IP,则您的 DHCP 一定配置错误。在这种情况下,您可能需要 /23 网络。

相关内容