Firefly开源社区

ubuntu18.04 如何通过命令行固定IP

42

积分

0

威望

0

贡献

技术小白

积分
42
发表于 2020-3-16 15:54:51     
ubuntu18.04 如何通过命令行固定IP呢?
回复

使用道具 举报

42

积分

0

威望

0

贡献

技术小白

积分
42
发表于 2020-3-16 16:21:14     
本帖最后由 闫涛 于 2020-3-16 16:25 编辑


ubuntu版本:Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:        18.04
Codename:       bionic



sudo apt-get install netplan.io
然后自己建一个01-netcfg.yaml 文件
内容为:
network:
version: 2
renderer: networkd
ethernets:
  eth0:
   dhcp4: no
   addresses: [192.168.1.203/24]
   gateway4: 192.168.1.1
   nameservers:
    addresses: [8.8.8.8,8.8.8.8]
ip信息,网关,dns,网卡信息根据自己的情况改。
然后把这个文件防到 /etc/netplan 下
执行sudo  netplan try  或者sudo netplan apply  就可以了  
sudo  netplan try 会 检查你的01-netcfg.yaml文件是不是有问题如果没有问题就会生效。

回复

使用道具 举报

3

积分

0

威望

0

贡献

吃瓜的群众

积分
3
发表于 2021-6-11 00:26:03     
格式调整
arm ubuntu18.04LTS
  1. # This file describes the network interfaces available on your system
  2. # For more information, see netplan(5).
  3. network:
  4.   version: 2
  5.   renderer: networkd
  6.   ethernets:
  7.     enp0s3:
  8.      dhcp4: no
  9.      addresses: [192.168.1.222/24]
  10.      gateway4: 192.168.1.1
  11.      nameservers:
  12.        addresses: [8.8.8.8,8.8.4.4]
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

友情链接 : 爱板网 电子发烧友论坛 云汉电子社区 粤ICP备14022046号-2
快速回复 返回顶部 返回列表