动态 版块 发帖 消息 我的
小绿叶技术博客
小绿叶技术博客
小绿叶技术Lv154   
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 改为正确的网卡名


【ubuntu20 版本配置】

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

network:
  ethernets:
    enp1s0:
        addresses: [192.168.122.80/24]
        dhcp4: no
        optional: true
        gateway4: 192.168.122.1
        nameservers: 
          addresses: [192.168.122.1,223.5.5.5]
  version: 2    
  renderer: NetworkManager


【ubuntu22 版本配置】解决报错: Ubuntu 22.10 netplan `gateway4` has been deprecated

network:
    ethernets:
        enp1s0:
            addresses:
            - 192.168.122.80/24
            dhcp4: false
            gateway4: 192.168.122.1
            nameservers:
                addresses:
                - 192.168.122.1
                search: []
    version: 2



  # 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      # 更新已安装的软件包


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

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

guest
登录之后更精彩~
Powered by HadSky 7.12.10
© 2015-2024 PuYueTian
您的IP:44.221.66.130,2024-06-20 14:49:24,Processed in 0.02689 second(s).
Powered by HadSky
小绿叶技术博客