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

Ubuntu20.0设置静态ip以及主机虚拟机的互ping

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

Ubuntu20.0设置静态ip以及主机虚拟机的互ping

一、修改文件/etc/netplan/xx-network-manager-all.yaml文件

刚安装的ubuntu操作系统,xx-network-manager-all.yaml文件名是不同的,进入到/etc/netplan/这个目录去查看具体是什么名称。

可以看到刚安装的ubuntu的network-manager-all.yaml是如下默认内容:

# This is the network config written by 'subiquity'
network:
  ethernets:
    ens33:
      dhcp4: true
  version: 2

这个缺省配置是动态IP的配置方式,考虑到这缺省配置的信息是安装操作系统阶段自动获得的,为了避免不知道怎么填具体参数,可以使用其他命令行查询网络配置信息。

root@server:~# ifconfig
ens33: flags=4163  mtu 1500
        inet 192.168.88.133  netmask 255.255.255.0  broadcast 192.168.88.255
        inet6 fe80::20c:29ff:fe8a:262d  prefixlen 64  scopeid 0x20
        ether 00:0c:29:8a:26:2d  txqueuelen 1000  (Ethernet)
        RX packets 227  bytes 25410 (25.4 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 142  bytes 16724 (16.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 96  bytes 7288 (7.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 96  bytes 7288 (7.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

root@server:~# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.88.2    0.0.0.0         UG    100    0        0 ens33
192.168.88.0    0.0.0.0         255.255.255.0   U     0      0        0 ens33
192.168.88.2    0.0.0.0         255.255.255.255 UH    100    0        0 ens33
root@server:~#
 

根据上面查询的信息修改xx-network-manager-all.yaml内容

# This is the network config written by 'subiquity'
network:
  ethernets:
    ens33:
      dhcp4: no
      addresses: [192.168.88.133/24]
      optional: true
      gateway4: 192.168.88.2
      nameservers:
        addresses: [223.5.5.5,223.6.6.6]
  version: 2


 

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

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

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