动态 版块 发帖 消息 我的
Loading...
小绿叶技术博客
小绿叶技术博客
小绿叶技术Lv149   
ubuntu20 修改网卡为静态指定ip 或者修改为动态ip,修改软件镜像为阿里云源 /etc/apt/sources.list     


1.  ubuntu 配置静态 ip ;   2. 修改为 动态ip  ;  3. ubuntu20 阿里云 apt 源 ;  4. ubuntu20 清华 apt 源。 apt update 与 apt upgrade 区别:只查看更新,和 更新软件包   

 #    修改为静态指定ip

ip a                           # 通过ip a 查看网卡名字,然后再下面配置中将 eth0 改为正确的网卡名



nano /etc/netplan/01-network-manager-all.yaml


network:

  ethernets:

    eth0:

        addresses: [10.111.111.200/24]

        dhcp4: no

        optional: true

        gateway4: 10.111.111.1

        nameservers: 

          addresses: [10.111.111.1,223.5.5.5]

  version: 2    

  renderer: NetworkManager

  # renderer 可不加,部分服务器加上这个参数网卡无法启动

  # 223.5.5.5  网络速度慢只有1M/s 速度,建议dns 修改为网关一个ip


sudo netplan apply                       # 生效配置



 #    修改动态获取ip

vi /etc/netplan/01-network-manager-all.yaml 


network:

  ethernets:

    eth0:

      dhcp4: true

  version: 2



sudo netplan apply                       # 生效配置

 #    ubuntu20 阿里云 apt 源

阿里云源 选择系统版本, 镜像仓库:https://developer.aliyun.com/mirror/


vi /etc/apt/sources.list



deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse


deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse


deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse


deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse


deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

 #    ubuntu20 清华 apt 源

清华apt 源选择版本:https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/


vi /etc/apt/sources.list


# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse

# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse

# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse

# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse


# 预发布软件源,不建议启用

# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse

# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse



apt update        # 命令更新软件源(只检查不更新)

apt upgrade      # 更新已安装的软件包


 0  已被阅读了442次  楼主 2022-04-04 14:28:48
回复列表

回复: ubuntu20 修改网卡为静态指定ip 或者修改为动态ip,修改软件镜像为阿里云源 /etc/apt/sources.list

guest
登录之后更精彩~
Powered by HadSky 7.7.16
© 2015-2022 PuYueTian
您的IP:8.219.134.200,2022-08-10 07:44:34,Processed in 0.01155 second(s).
Powered by HadSky
小绿叶技术博客