当前位置:首页 > HOTMAIPU > 正文

Ubuntu固定IP设置

HOTMAIPU · Jun 03, 2026

Ubuntu 网络配置与阿里云源设置

1. 网络配置(Netplan 示例)

network: 
  version: 2 
  ethernets: 
    ens33: 
      addresses: 
        - 192.168.66.106/24 
      routes: 
        - to: default 
        via: 192.168.66.254 
      nameservers: 
        addresses: 
        - 8.8.8.8 
        - 114.114.114.114 
      dhcp4: false

2. Ubuntu 阿里云镜像源配置

将以下内容添加到 /etc/apt/sources.list 文件中,替换原有源即可:

deb https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse 
deb-src https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse  

deb https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse 
deb-src https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse  

deb https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse 
deb-src https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse  

# 以下为可选源,默认注释 
# deb https://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse 
# deb-src https://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse  

deb https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse 
deb-src https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse

3. 配置说明

  • 网络配置
    • 静态IP:192.168.66.106/24
    • 默认网关:192.168.66.254
    • DNS服务器:8.8.8.8、114.114.114.114
    • DHCP:已关闭
  • 阿里云源
  • 适用于 Ubuntu Noble 版本
  • 包含主仓库、更新、安全、回溯等源
  • 可选 proposed 源默认注释,按需开启

4. 常用操作

  1. 应用网络配置

sudo netplan apply

  1. 更新软件源

sudo apt update sudo apt upgrade

💡 如有更多配置需求,可根据实际情况调整相关参数。