admin管理员组文章数量:1625483
ubuntu从17.10开始,已放弃在/etc/network/interfaces里固定IP的配置,即使配置也不会生效,而是改成netplan方式 ,配置写在/etc/netplan/01-netcfg.yaml或者类似名称的yaml文件里,18.04的server版本安装好以后,配置文件是:/etc/netplan/50-cloud-init.yaml,修改配置以后不用重启,执行 netplan apply 命令可以让配置直接生效。以前的重启网络服务命令/etc/init.d/networking restart或者services network restrart也都会提示为无效命令。
为了方便使用树莓派,我准备将树莓派的网线口设置为固定IP,无线设置为DHCP。
首先查看无线网卡
其中的wlan0是无线网卡的名称。
$sudo vim /etc/netplan/50-cloud-init.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}
network:
ethernets:
eth0:
#dhcp4: true
dhcp4: false
addresses: [192.168.2.226/24]
gateway4: 192.168.2.1
nameservers:
addresses: [192.168.2.1]
optional: true
wifis:
wlan0:
dhcp4: true
optional: true
access-points:
"你的wifi名称":
password: "你的wifi密码"
version: 2
其中,addresses里的 24是掩码,查询,对应关系见下图
修改完成后保存,netplan apply启动。
netplan apply
如果报错,根据报错提示修改50-cloud-init.yaml,直至不报错……
经过无数次修改,终于OK了……
版权声明:本文标题:ubuntu 18.04设置固定ip以及无线网卡配置。 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1728930429a1180342.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论