通过以太网将 Linux Ubuntu 连接到网络

通过以太网将 Linux Ubuntu 连接到网络

我有一台装有 Linux Ubuntu 16.04 的笔记本电脑,我想通过以太网连接来访问互联网。问题是 - 在 95% 的通过以太网连接的尝试中,笔记本电脑需要很长时间才能获取 IP 地址。大约需要 5-10 分钟。在其他 5% 的尝试中,笔记本电脑大约需要 30 秒才能获取其地址。

这是我的/etc/network/interfaces文件:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet dhcp

那是我的/etc/dhcp/dhclient.conf

# Configuration file for /sbin/dhclient, which is included in Debian's
#   dhcp3-client package.
#
# This is a sample configuration file for dhclient. See dhclient.conf's
#   man page for more information about the syntax of this file
#   and a more comprehensive list of the parameters understood by
#   dhclient.
#
# Normally, if the DHCP server provides reasonable information and does
#   not leave anything out (like the domain name, for example), then
#   few changes must be made to this file, if any.
#

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;

#send host-name "andare.fugue.com";
send host-name = gethostname();
#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
#send dhcp-lease-time 3600;
#supersede domain-name "fugue.com home.vix.com";
#prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
    domain-name, domain-name-servers, domain-search, host-name,
    dhcp6.name-servers, dhcp6.domain-search,
    netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers,
    dhcp6.fqdn, dhcp6.sntp-servers;
#require subnet-mask, domain-name-servers;
timeout 60;
#retry 60;
#reboot 10;
#select-timeout 5;
#initial-interval 2;
#script "/etc/dhcp3/dhclient-script";
#media "-link0 -link1 -link2", "link0 link1";
#reject 192.33.137.209;

#alias {
#  interface "eth0";
#  fixed-address 192.5.5.213;
#  option subnet-mask 255.255.255.255;
#}

#lease {
#  interface "eth0";
#  fixed-address 192.33.137.200;
#  medium "link0 link1";
#  option host-name "andare.swiftmedia.com";
#  option subnet-mask 255.255.255.0;
#  option broadcast-address 192.33.137.255;
#  option routers 192.33.137.250;
#  option domain-name-servers 127.0.0.1;
#  renew 2 2000/1/12 00:00:01;
#  rebind 2 2000/1/12 00:00:01;
#  expire 2 2000/1/12 00:00:01;
#}

sudo ifup eth0最后这是(我的以太网接口是)的输出eth0

Internet Systems Consortium DHCP Client 4.3.3
Copyright 2004-2015 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/eth0/80:fa:5b:28:8a:a7
Sending on   LPF/eth0/80:fa:5b:28:8a:a7
Sending on   Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3 (xid=0x9e33c853)
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7 (xid=0x9e33c853)
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 13 (xid=0x9e33c853)
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 13 (xid=0x9e33c853)
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 13 (xid=0x9e33c853)
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 12 (xid=0x9e33c853)
No DHCPOFFERS received.
No working leases in persistent database - sleeping

ping 192.168.1.1这是我在sudo ifup eth0命令后立即启动的输出:

PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.

该行命令挂起约 7-10 分钟后,然后:

64 bytes from 192.168.1.1: icmp_seq=297 ttl=64 time=0.542 ms
64 bytes from 192.168.1.1: icmp_seq=298 ttl=64 time=0.446 ms
64 bytes from 192.168.1.1: icmp_seq=299 ttl=64 time=0.320 ms
64 bytes from 192.168.1.1: icmp_seq=300 ttl=64 time=0.459 ms
64 bytes from 192.168.1.1: icmp_seq=301 ttl=64 time=0.444 ms
64 bytes from 192.168.1.1: icmp_seq=302 ttl=64 time=0.409 ms
64 bytes from 192.168.1.1: icmp_seq=303 ttl=64 time=0.519 ms
64 bytes from 192.168.1.1: icmp_seq=304 ttl=64 time=0.454 ms
64 bytes from 192.168.1.1: icmp_seq=305 ttl=64 time=0.501 ms

因此,很明显,在 ping 挂起的整个过程中,笔记本电脑都在获取 IP 地址。所以我的问题是 - 我应该怎么做才能让我的 Linux Ubuntu 尽快获取 IP 地址?笔记本电脑可能遇到什么障碍?

附言:我换了一个路由器。情况没有改变,所以显然我的 Linux 设置出了问题。我非常确定它可以更快地获得 IP 地址,因为有时以太网连接在大约 30 秒内就可以准备好,这对我来说是可行的。

任何帮助都将不胜感激。提前致谢!

添加:

以下是命令的输出sudo lshw -c network

*-network
      description: Ethernet interface
      product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
      vendor: Realtek Semiconductor Co., Ltd.
      physical id: 0.1
      bus info: pci@0000:01:00.1
      logical name: eth0
      version: 12
      serial: 80:fa:5b:28:8a:a7
      size: 100Mbit/s
      capacity: 1Gbit/s
      width: 64 bits
      clock: 33MHz
      capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
      configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=full firmware=rtl8411-2_0.0.1 07/08/13 latency=0 link=yes multicast=yes port=MII speed=100Mbit/s
      resources: irq:16 ioport:e000(size=256) memory:df114000-df114fff memory:df110000-df113fff
 *-network DISABLED
      description: Wireless interface
      product: Wireless 8260
      vendor: Intel Corporation
      physical id: 0
      bus info: pci@0000:02:00.0
      logical name: wlan0
      version: 3a
      serial: a4:34:d9:53:52:37
      width: 64 bits
      clock: 33MHz
      capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless
      configuration: broadcast=yes driver=iwlwifi driverversion=4.15.0-29-generic firmware=22.391740.0 latency=0 link=no multicast=yes wireless=IEEE 802.11
      resources: irq:128 memory:df000000-df001fff

相关内容