2

我正在尝试为我的 Linux Ubuntu 18.04 设置静态 IP。我发现了一些在 /etc/netplan/ 中创建文件 01-netcfg.yaml 的建议。我在那里写道:

network:
    version: 2                                
    renderer: networkd
    ethernets:
        wifi0:
          addresses: [192.168.1.2/24]
          gateway4: 192.168.1.255
          nameservers:
            addresses: [8.8.4.4, 8.8.8.8]

这是我得到的sudo netplan apply

System has not been booted with systemd as init system (PID 1). Can't operate. 
   Traceback (most recent call last):
    File "/usr/sbin/netplan", line 23, in <module>                                 netplan.main()                                                             
    File "/usr/share/netplan/netplan/cli/core.py", line 50, in main                self.run_command()                                                         
    File "/usr/share/netplan/netplan/cli/utils.py", line 130, in run_command       self.func()                                                                
    File "/usr/share/netplan/netplan/cli/commands/apply.py", line 43, in run       self.run_command()                                                         
    File "/usr/share/netplan/netplan/cli/utils.py", line 130, in run_command       self.func()                                                                             
    File "/usr/share/netplan/netplan/cli/commands/apply.py", line 75, in command_apply
            utils.systemctl_networkd('stop', sync=sync, extra_services=['netplan-wpa@*.service']) \
    File "/usr/share/netplan/netplan/cli/utils.py", line 82, in systemctl_networkd 
    subprocess.check_call(command)                                             
    File "/usr/lib/python3.6/subprocess.py", line 291, in check_call               
        raise CalledProcessError(retcode, cmd)                                       
    subprocess.CalledProcessError: Command '['systemctl', 'stop', '--no-block', 'systemd-networkd.service', 'netplan-wpa@*.service']' returned non-zero exit status 1.

这是我所拥有的ip a(尝试设置wifi0):

1: lo: <LOOPBACK,UP> mtu 1500 group default qlen 1
   link/loopback 00:00:00:00:00:00                                                                       
   inet 127.0.0.1/8 brd 127.255.255.255 scope global dynamic                                                
   valid_lft forever preferred_lft forever                                                            
   inet6 ::1/128 scope global dynamic                                                                       
   valid_lft forever preferred_lft forever                                                        

12: wifi0: <BROADCAST,MULTICAST,UP> mtu 1500 group default qlen 1                                         
   link/ieee802.11 68:a3:c4:92:1a:a5                                                                     
   inet 192.168.1.2/24 brd 192.168.1.255 scope global dynamic                                               
   valid_lft 86213sec preferred_lft 86213sec                                                          
   inet6 fe80::4c78:b522:564f:ff24/64 scope global dynamic                                                  
   valid_lft forever preferred_lft forever

我无法解释这个 PID 1 错误。谢谢你的帮助!

4

0 回答 0