栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

Ubuntu 20.04 LTS 修改IP地址

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Ubuntu 20.04 LTS 修改IP地址

Ubuntu 20.04 LTS 修改IP地址

Ubuntu 20.04 LTS系统中修改IP地址,将DHCP自动分配的IP地址192.168.1.66改为静态IP地址192.168.1.75。

查看IP地址
ens18: flags=4163  mtu 1500
        inet 192.168.1.66  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::4029:99ff:febe:719f  prefixlen 64  scopeid 0x20
        ether 42:29:99:be:71:9f  txqueuelen 1000  (Ethernet)
        RX packets 2494  bytes 306105 (306.1 KB)
        RX errors 0  dropped 22  overruns 0  frame 0
        TX packets 384  bytes 51282 (51.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
查看netplan配置文件
$ sudo cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
  ethernets:
    ens18:
      dhcp4: true
  version: 2

默认配置是采用DHCP自动获取动态IP。

备份netplan配置文件
sudo cp /etc/netplan/00-installer-config.yaml /etc/netplan/00-installer-config_backup.yaml 
修改netplan配置文件
$ sudo vim /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
  ethernets:
    ens18:
      dhcp4: no
      addresses: [192.168.1.75/24,]
      gateway4: 192.168.1.1
      nameservers:
        addresses: [8.8.8.8, 127.0.0.53]
  version: 2

更多netplan命令参考官方网站。

检测netplan配置
$ sudo netplan try
Warning: Stopping systemd-networkd.service, but it can still be activated by:
  systemd-networkd.socket
Do you want to keep these settings?


Press ENTER before the timeout to accept the new configuration


Changes will revert in 117 seconds
Configuration accepted.

  • netplan try:应用配置并等待用户确认;如果网络损坏或未给出确认,将回滚。

  • netplan apply:应用渲染器的所有配置,必要时重新启动它们。

再次查看IP地址
ens18: flags=4163  mtu 1500
        inet 192.168.1.75  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::4029:99ff:febe:719f  prefixlen 64  scopeid 0x20
        ether 42:29:99:be:71:9f  txqueuelen 1000  (Ethernet)
        RX packets 61995  bytes 4987543 (4.9 MB)
        RX errors 0  dropped 22  overruns 0  frame 0
        TX packets 3769  bytes 2592311 (2.5 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/296320.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号