0
点赞
收藏
分享

微信扫一扫

解决ubuntu16.04的apt-get update慢以及无法ping www.baidu.com的问题

Greatiga 2023-05-07 阅读 49


文章目录

  • 1.Ubuntu 可以ping通DNS 无法访问外网的问题
  • 2.解决ubuntu16.04的apt-get update慢的问题
  • 3.解决VMware扩容Ubuntu系统的方法
  • 4.解决ubuntu18找不到网络适配器,无法连接网络
  • 5.更改pip源至清华、阿里镜像
  • 6.ubuntu开启CoreDump
  • 7.Ubuntu 18.04: Install PlantUML for UML tool

1.Ubuntu 可以ping通DNS 无法访问外网的问题

  • 在解决解决ubuntu16.04的apt-get update慢之前,需要查看你的ubuntu是否能ping www.baidu.com,如果不可以需要按照以下的步骤来进行设置
  • (1)打开VMware的网络配置:编辑->虚拟网络编辑器
  • 解决ubuntu16.04的apt-get update慢以及无法ping www.baidu.com的问题_vm

  • (2)首先看一下你的静态ip地址,子网掩码,网关,dns地址(设置静态ip需要dns进行域名解析,需要配置dns地址)是否缺少

vim /etc/network/interfaces
进行相关的设置:参数如下,注意:下面的gateway 需要依据你的Vm虚拟机获取的网关进行设置

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

auto ens33
iface ens33 inet static
#onboot=yes
#

address 192.168.13.130
gateway 192.168.13.2

netmask 255.255.255.0
dns-nameserver 119.29.29.29
dns-nameserver 114.114.114.114
dns-nameserver 8.8.8.8

  • (3)ip地址—首先看一下ip地址和windows主机的地址是否在同一网段,可以ping测试一下
  • (4)DNS地址—查看dns地址,dns地址可以在/etc/network/interfaces文件中配置,也可以在/etc/resolvconf/resolv.conf.d/base中(具体配置可以看步骤一的图),
    配置完成执行/etc/init.d/networking restart;
    然后cat /etc/resolv.conf文件可以看到你配置的dns地址(注意不要直接修改/etc/resolv.conf这个文件,因为重启网络后,这里面的内容会重新生成);
    最后ping一下dns地址,看是否能够ping通.

/etc/init.d/networking restart
root@ubuntu:/home/jiwangreal# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=128 time=107 ms


root@ubuntu:/home/jiwangreal# cat /etc/resolv.conf 
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 119.29.29.29
nameserver 114.114.114.114
nameserver 8.8.8.8

  • 参考:ubuntu resolvconf 设置永久dns,可以永久设置任意N个DNS

1. 安装resolvconf#
sudo apt install -y resolvconf

2. 修改head#
vim /etc/resolvconf/resolv.conf.d/head
在 head中添加你想使用的dns

nameserver 8.8.8.8
nameserver 114.114.114.114
3. 刷新/etc/resolv.conf#
执行resolvconf -u命令来刷新/etc/resolv.conf 就可以看到在resolv.conf的开头已经有了你在head中添加的nameserver

nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 114.114.114.114

  • (5)网关—使用netstat -rn命令查看路由信息,如果没有网关,需要在添加,
    如下说明网关已经配置好了

root@ubuntu:/home/jiwangreal# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.13.2    0.0.0.0         UG        0 0          0 ens33
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 ens33
172.17.0.0      0.0.0.0         255.255.0.0     U         0 0          0 docker0
192.168.13.0    0.0.0.0         255.255.255.0   U         0 0          0 ens33
192.168.13.0    0.0.0.0         255.255.255.0   U         0 0          0 br-8c703de3f949

  • (6)dns域名是否开启 --查看/etc/nsswitch.conf文件中的hosts一行是否dns

root@ubuntu:/home/jiwangreal# cat /etc/nsswitch.conf
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.

passwd:         compat
group:          compat
shadow:         compat
gshadow:        files

hosts:          files mdns4_minimal [NOTFOUND=return] dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

  • 参考:

Ubuntu 可以ping通DNS 无法访问外网的问题

2.解决ubuntu16.04的apt-get update慢的问题

  • 直接修改国内的镜像源即可,因为ubuntu配置的默认源死过外的服务器,这可以通过以下的命令可以去查看相关的内容
  • 建议使用清华源

vim /etc/apt/sources.list

  • 参考:【Ubuntu】Ubuntu 18.04 LTS 更换国内源——解决终端下载速度慢的问题,清华大学开源软件镜像站

注意ubuntu的Codename:问题,我这台叫jammy,需要按照这个去修改源,要不然下载的包各种报错
wangji@DESKTOP-9TAUMH9:~/packets/cmake-3.25.0-rc1$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.1 LTS
Release: 22.04
Codename: jammy
eg报错:libc6-dev: 依赖: libc6 (= 2.27-3ubuntu1.3) 但是 2.31-0ubuntu9.1 正要被安装…

3.解决VMware扩容Ubuntu系统的方法

(1)大致步骤:先在vm中调整硬盘大小,接着在vm的ubuntu中使用gparted扩容对应分区目录,参考:vmware:ubuntu虚拟机如何扩容? (2)若未安装gparted,则参考:How to Install Gparted on Ubuntu 20.04

4.解决ubuntu18找不到网络适配器,无法连接网络

出现问题如下:ubuntu18.04没有网络,网络中或者右上角没有有线设置

  • 在网络设置中仅有VPN和网络代理,没有有线设置
  • 在这块没有显示有关网络的任何信息

解决办法

  • 使用普通用户去做

1.打开终端,运行命令:

  sudo service network-manager stop

  sudo gedit /var/lib/NetworkManager/NetworkManager.state

2.更改打开的文件里的内容:

  将 NetworkingEnabled=false 改为 NetworkingEnabled=true

3.保存退出后,在终端运行命令:

  sudo service network-manager start

5.更改pip源至清华、阿里镜像

可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple
阿里云源是: -i http:// https://mirrors.aliyun.com/pypi/simple

6.ubuntu开启CoreDump

(1)查看是否打开了coredump

临时修改:
ulimit -c 1024
ulimit -c unlimited    //大小不受限

永久修改:
vim /etc/profile,然后添加上面的命令ulimit - c unlimited.然后执行source /etc/profile或者重启使刚刚的配置可以生效。

(2)设置core文件存储路径

man core
sudo sysctl -a|grep -i pattern

kernel.core_pattern = /var/core/core_%e_%p   
kernel.core_uses_pid = 0   //是否加上pid

修改/etc/default/apport文件,enabled 设置为0
cat /proc/sys/kernel/core_pattern
/var/core/core_%e_%p

7.Ubuntu 18.04: Install PlantUML for UML tool

Install PlantUML

  • Install plantuml.jar to /opt/plantuml.

#!/bin/sh -e


sudo apt install -y graphviz default-jre

sudo mkdir -p /opt/plantuml
cd /opt/plantuml
UML=http://sourceforge.net/projects/plantuml/files/plantuml.jar/download
sudo curl -JLO ${UML}

cat <<EOF | sudo tee /usr/local/bin/plantuml
#!/bin/sh

java -jar /opt/plantuml/plantuml.jar "\$@"
EOF
sudo chmod a+x /usr/local/bin/plantuml

Create UML diagram

  • Create sequence.png from sequence.pu.

#!/bin/sh

cat <<EOF > sequence.pu
@startuml
Alice -> Bob: test
@enduml
EOF
plantuml sequence.pu

结果

解决ubuntu16.04的apt-get update慢以及无法ping www.baidu.com的问题_ubuntu_02

  • 参考:ubuntu18找不到网络适配器,无法连接网络,更改pip源至清华、阿里镜像,ubuntu20.04 如何生成core文件,Ubuntu 18.04: Install PlantUML for UML tool


举报

相关推荐

0 条评论