静态 IP 和 netplan

静态 IP 和 netplan

我正在尝试在 Ubuntu 中创建静态 IP 地址。我研究了帖子等,发现这些信息是/etc/network/interfaces。我注意到以太网名称不一致:

iface ens3 inet static
    address 192.168.122.100
    netmask 255.255.255.0
    gateway 192.168.122.1
    dns-nameservers 8.8.8.8

/etc/netplan/ens3.yaml除了创建包含以下内容的文件外

network:
    version: 2
    ethernets:
        ens3:
            dhcp4: no
            addresses: [192.168.122.100/24]
            gateway4: 192.168.122.1
            nameservers:
                addresses: [8.8.8.8]

当然,我的系统的所有 IP 地址都需要更改。

我还需要有关如何使用 wlan 执行此操作的关键字。

我走的路对吗?任何信息都将不胜感激。

ubuntu@ubuntu:~$ ls -al /etc/netplan  
total 28  
drwxr-xr-x   2 root root  4096 Nov  7 05:24 .  
drwxr-xr-x 142 root root 12288 Nov  7 06:05 ..  
-rw-r--r--   1 root root   683 Sep 24 19:27 50-cloud-init.yaml  
-rw-r--r--   1 root root   207 Nov  6 22:48 eth0.old_yaml  
-rw-r--r--   1 root root   293 Nov  7 04:41 wlan0.old_yaml'''
ubuntu@ubuntu:~$ cat /etc/netplan/*.yaml  
# This file is generated from information provided by the datasource.  Changes  
# to it will not persist across an instance reboot.  To disable cloud-init's  
# network configuration capabilities, write a file  
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:  
# network: {config: disabled}
ubuntu@ubuntu:/etc/netplan$ cat eth0.yaml  
network:  
    version: 2  
    renderer: networkd  
    ethernets:  
      eth0:  
        dhcp4: no  
        addresses: [192.168.0.220/24]  
        gateway4: 192.168.0.1  
        nameservers:  
          addresses: [68.105.28.11,8.8.8.8]  
ubuntu@ubuntu:/etc/netplan$ cat wlan0.yaml  
network:  
  version: 2  
  renderer: networkd  
  wifis:  
    wlan0:  
      dhcp4: no  
      dhcp6: no  
      addresses: [192.168.0.221/24]  
      gateway4: 192.168.0.1  
      nameservers:  
        addresses: [68.105.28.11, 8.8.8.8]  
      access-points:  
        "xxxxxxx":
        password: "xxxxxxxx"  
ubuntu@ubuntu:/etc/cloud/cloud.cfg.d$ cat 99-disable-network-config.cfg
network:
  config: disabled
ubuntu@ubuntu:/etc/netplan$ hostname -I
192.168.0.44 2600:8802:3500:f400:798d:ff80:901c:e944 

相关内容