树莓派安装ubuntu,设置静态ip,通过SSH连接

ubuntu系统默认登录账号和密码均为ubuntu

本例设置静态IP适用于 Ubuntu 18.04 LTS、 Ubuntu 20.04 LTS

查看 ubuntu 版本号

// 系统版本
$ cat /etc/issue

// 内核版本
$ uname -a

查看当前ip

1.
$ ip addr 

2.
$ ifconfig -a

设置静态IP

修改网络配置文件

$ sudo vi /etc/netplan/50-cloud-init.yaml

设置IP地址为 192.168.1.126, 子网掩码24位即255.255.255.0, 网关为192.168.1.1, DNS1: 233.5.5.5, DNS2: 8.8.8.8

# 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: no
            addresses: [192.168.1.126/24]
            optional: true
            gateway4: 192.168.1.1
            nameservers:
                    addresses: [223.5.5.5,8.8.8.8]
    version: 2

运行命令应用新配置,立即生效

$ sudo netplan apply

测试网络连通

$ ping 192.168.1.126
$ ping www.baidu.com
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值