rk3568 ubuntu20 静态IP配置

1、配置静态ip

cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto eth0
iface eth0 inet static
address 192.168.0.177
gateway 192.168.0.1
netmask 255.255.255.0

nameserver 114.114.114.114

2、重启系统,查看ip配置

ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.177  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::2ca6:48ff:fe7e:579  prefixlen 64  scopeid 0x20<link>
        ether 2e:a6:48:7e:05:79  txqueuelen 1000  (Ethernet)
        RX packets 2303  bytes 655134 (655.1 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 394  bytes 35899 (35.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 37  

3、ping同网关ip

ping 192.168.0.82
PING 192.168.0.82 (192.168.0.82) 56(84) bytes of data.
64 bytes from 192.168.0.82: icmp_seq=1 ttl=64 time=1.31 ms
64 bytes from 192.168.0.82: icmp_seq=2 ttl=64 time=0.878 ms
64 bytes from 192.168.0.82: icmp_seq=3 ttl=64 time=0.883 ms
64 bytes from 192.168.0.82: icmp_seq=4 ttl=64 time=0.981 ms

4、ping外网失败

ping www.baidu.com
ping: www.baidu.com: Temporary failure in name resolution

5、修改/etc/resolv.conf配置

cat /etc/resolv.conf 
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients directly to
# all known uplink DNS servers. This file lists all configured search domains.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 8.8.8.8

......

ping www.baidu.com
PING www.a.shifen.com (14.119.104.189) 56(84) bytes of data.
64 bytes from 14.119.104.189 (14.119.104.189): icmp_seq=1 ttl=56 time=4.87 ms
64 bytes from 14.119.104.189 (14.119.104.189): icmp_seq=2 ttl=56 time=5.01 ms
64 bytes from 14.119.104.189 (14.119.104.189): icmp_seq=3 ttl=56 time=4.82 ms
64 bytes from 14.119.104.189 (14.119.104.189): icmp_seq=4 ttl=56 time=5.40 ms
^C
--- www.a.shifen.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 7029ms
rtt min/avg/max/mdev = 4.824/5.025/5.398/0.226 ms

6、重启系统后/etc/resolv.conf文件失效,再次无法连接以太网

7、在 Ubuntu 20.04 中,/etc/resolv.conf 文件是由 systemd-resolved 服务动态生成的。需要手动编辑此文件,更改将在系统重新启动时丢失。

打开 /etc/systemd/resolved.conf 文件,并编辑 DNS=FallbackDNS=

cat /etc/systemd/resolved.conf 
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details

[Resolve]
DNS=8.8.8.8
FallbackDNS=8.8.4.4
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#DNSOverTLS=no
#Cache=no-negative
#DNSStubListener=yes
#ReadEtcHosts=yes

8、保存更改后,运行以下命令以重新加载 systemd-resolved 服务

sudo systemctl restart systemd-resolved.service

9、更新 /etc/resolv.conf 文件以指向 systemd-resolved 服务。可以通过创建符号链接来实现这一点。运行以下命令:

sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf

10、再次ping百度,连接正常

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值