侧边栏壁纸
博主头像
daixinmini的小屋博主等级

阿巴阿巴阿巴

  • 累计撰写 11 篇文章
  • 累计创建 4 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

Ubuntu 设置固定ip地址

380025303@qq.com
2023-10-16 / 0 评论 / 0 点赞 / 80 阅读 / 1214 字

ubuntu 旧版本

修改interfaces

sudo vi /etc/network/interfaces

auto enp1s0  # 网卡名称
iface enp1s0 inet static #设置为静态IP
address 192.168.1.100    # 本机IP
netmask 255.255.255.0    # 子网掩码
gateway 192.168.0.1      # 网关

增加DNS

sudo vi /etc/resolv.conf

nameserver 223.5.5.5
nameserver 8.8.8.8

重启

reboot

ubuntu 新版本

sudo vi /etc/netplan/00-installer-config.yaml

# This is the network config written by 'subiquity'
network:
  ethernets:
    # 网卡名称
    eno1:
      # 禁用DHCP
      dhcp4: false
      # 本机IP/子网掩码
      addresses: [192.168.0.20/24]
      # 网关
      routes:
        - to: default
          via: 192.168.0.1
      nameservers:
        addresses: [223.5.5.5, 114.114.114.114]
  version: 2

netnetplan applyplan apply

netplan apply

0
  • ${post.likes!0}

评论区