Linux实践归纳 | Ubuntu18.04-LTS配置静态IP

由于博主是在ARM板上配置静态ip,ARM平台使用的是Ubuntu18.04-LTS系统,在参考其他博主的文章后,发现Ubuntu18版本与16版本的网络配置有点不一样,通过折腾一个下午,终于配置成功并成功ping通外网!

文章目录

  • 1、01-network-manager-all.yaml文件配置
  • 2、resolved.conf文件配置
  • 3、网络IP相关知识
  • 4、若文章对您有帮助,关注+点赞+收藏,定期发好文

1、01-network-manager-all.yaml文件配置

cd进入到/etc/netplan/目录下,执行vim 01-network-manager-all.yaml命令,如果没有netplan目录或者01-network-manager-all.yaml文件,自行创建即可。参考以下内容:

#Let NetworkManager manage all devices on this system
network:
  version: 2
#  renderer: NetworkManager
  ethernets:
          eth0:
                  addresses: [168.168.100.111/16]
                  gateway4:  168.168.0.1
                  dhcp4: no
                  dhcp6: no
                  nameservers: 
                        addresses: [127.0.0.53, 114.114.114.114, 114.114.115.115, 8.8.8.8, 8.8.4.4]
  • eth0为网络设备接口名称,addressed为需要配置的ip地址信息,后面的16为子网掩码,代表255.255.0.0,需要用命令ifconfig -a查看自己的网络信息进行配置
  • gateway4ip4网关,不清楚网关可执行命令route -n进行查看
  • nameserversaddressesDNS地址,国内一般选择114.114.114.114或者114.114.115.115

2、resolved.conf文件配置

cd进入到/etc/systemd/目录下,执行vim 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=127.0.0.53 114.114.114.114 114.114.115.115 8.8.8.8 8.8.4.4
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=yes

3、网络IP相关知识

  • 如果想了解网络IP相关知识,推荐参考文章:https://blog.csdn.net/weixin_42724467/article/details/90293151

4、若文章对您有帮助,关注+点赞+收藏,定期发好文

Linux实践归纳 | Ubuntu18.04-LTS配置静态IP_第1张图片

你可能感兴趣的:(Linux)