ubuntu 18.04网络问题

准备工作

安装好系统之后,检查gcc和make是否已经安装

$ which gcc
/usr/bin/gcc
$ which make
/usr/bin/make

如果未安装,则安装gcc和make

$ apt install gcc
$ apt install make

安装openssh-server

$ apt install openssh-server

安装网络工具和防火墙

$ apt install net-tools
$ apt install ufw

开通端口

$ ufw allow 22

一、有线网卡不可用

准备设置静态IP时,发现没有有线网卡,无法正常插网线进行联网。
在这里插入图片描述
执行ipconfig 查看网卡配置是否有ethxx或者enxx,也没有,则说明有线网卡的驱动需要更新。

前往Intel官网下载驱动 , 选择3.8.4版本下载, 然后将下载的软件e1000e-3.8.4.tar.gz通过U盘拷贝到服务器。

解压e1000e-3.8.4.tar.gz安装包文件

$ tar -zxvf e1000e-3.8.4.tar.gz

或者

$ gunzip e1000e-3.8.4.tar.gz 
$ tar xvf e1000e-3.8.4.ta

编译有线网卡驱动

$ cd e1000e-3.8.4/src
$ sudo make
*** disabled for this build.
make[1]: Entering directory '/usr/src/linux-headers-4.15.0-142-generic'
  Building modules, stage 2.
  MODPOST 1 modules
make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-142-generic'

安装有线网卡驱动

$ sudo make install
*** The target kernel has CONFIG_MODULE_SIG_ALL enabled, but
*** the signing key cannot be found. Module signing has been
make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-142-generic'
Running depmod...

启用有线网卡启动,如果没有报错,正常情况下可以看到有线网卡已经正常可用了。

$ sudo modprobe e1000e

如果遇到modprobe: ERROR: could not insert ‘e1000e’: Required key not available,这是因为从内核4.4.0-20 开始启用EFI_SECURE_BOOT_SIG_ENFORCE编译选项,如果启用UEFI Secure Boot,将禁止加载未签名的第三方驱动。
在这里插入图片描述
重启电脑,按ESC进Blos-->secuity-->secure boot-->enabled,重新进入系统,以太网正常连接。

二、无法访问外网

服务器上部署了docker镜像后,调用接口提示无法访问外网,去服务器上查看,确实无法ping通百度。

$ ping www.baidu.com
ping: www.baidu.com: 未知的名称或服务

修改并应用网口信息,并重启网络

$ vim  /etc/network/interfaces
$ cat  /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eno1
iface eno1 inet static
address 192.168.248.142
gateway 192.168.248.254
netmask 255.255.255.0
dns-nameserver 192.168.42.161
dns-nameserver 8.8.8.8

$ netplan apply
$ systemctl restart networking

再次ping百度还是不同

$ ping www.baidu.com
ping: www.baidu.com: 未知的名称或服务

查看域名解析配置文件,发现里面的nameserver和我们的dns配置不一致。

$ cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 127.0.0.53
options edns0

修改域名解析配置文件如下,保存并退出

$ vim /etc/resolv.conf
nameserver 192.168.42.161
options eno1

再次ping百度,成功。

$ ping www.baidu.com
PING www.a.shifen.com (183.2.172.42) 56(84) bytes of data.
64 bytes from 183.2.172.42 (183.2.172.42): icmp_seq=1 ttl=51 time=7.02 ms
64 bytes from 183.2.172.42 (183.2.172.42): icmp_seq=2 ttl=51 time=7.06 ms
^C
--- www.a.shifen.com ping statistics ---
9 packets transmitted, 9 received, 0% packet loss, time 9079ms
rtt min/avg/max/mdev = 6.393/7.012/8.473/0.798 ms

如果你的docker镜像启动的时候network_mode选择的是host,则还需要重启一次容器,否则程序还是不能访问到外网。

三、软件下载慢

安装系统完毕,网络设置正常后一般都需要执行对系统软件进行更新、升级、安装

$ apt-get update
$ apt-get upgrade -y 
$ apt-get -f install

如果下载特别慢,就需要考虑替换软件源为国内的源。

查看原有的源列表文件

$ cat /etc/apt/sources.list

备份源文件

$ cd /etc/apt
$ cp sources.list sources.list.back

修改源文件

$ vim sources.list
##阿里云源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

保存源文件后,重新执行更新操作。

  • 10
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
如果您的Ubuntu 18.04无法连接到互联网,您可以尝试以下步骤: 1.检查网络连接:首先,请确保您的网络连接正常。您可以尝试使用其他设备检查网络连接是否正常。如果其他设备可以连接到互联网,则可能是Ubuntu系统的问题。 2.检查网络设置:确保您的网络设置正确。您可以打开“设置”应用程序,然后选择“网络”选项卡,查看您的网络设置。如果您使用的是有线连接,请确保网线连接到计算机和路由器/调制解调器。 3.检查网络驱动程序:有时可能需要安装正确的网络驱动程序才能连接到互联网。您可以打开终端并输入以下命令来检查您的网络驱动程序: sudo lshw -C network 该命令将列出您的网络适配器和相关驱动程序。如果您的适配器未列出或驱动程序未正确加载,则需要安装或更新驱动程序。 4.重启网络服务:有时重启网络服务可以解决网络问题。您可以打开终端并输入以下命令: sudo service network-manager restart 该命令将重启网络服务。 5.检查防火墙设置:防火墙可能会阻止您的Ubuntu系统连接到互联网。您可以打开终端并输入以下命令来检查您的防火墙设置: sudo ufw status 如果防火墙已启用并阻止了Internet连接,请禁用防火墙或添加必要的规则以允许Internet连接。 这些是一些可能有助于解决Ubuntu 18.04网络问题的步骤。如果问题仍然存在,请尝试搜索问题的更多解决方案,或者联系您的网络管理员或技术支持。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值