ubuntu 20.04配置网络
1、系统
root@utuntu01:/home# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.4 LTS Release: 20.04 Codename: focal
2、修改配置文件
root@utuntu01:/home# vim /etc/netplan/00-installer-config.yaml # This is the network config written by 'subiquity' network: ethernets: ens32: addresses: - 192.168.xx.xx/24 ## 此处改为自己的IP gateway4: 192.168.xx.1 ## 网关 nameservers: addresses: - 119.29.29.29 version: 2
保存退出:
3、执行netplan apply
root@utuntu01:/home# netplan apply ## 没有报错,说明配置没有问题
4、查看ip
root@utuntu01:/home# ifconfig | head ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.3.24 netmask 255.255.255.0 broadcast 192.168.3.255 ether 00:0c:29:eb:97:ee txqueuelen 1000 (Ethernet) RX packets 7294 bytes 10054200 (10.0 MB) RX errors 0 dropped 286 overruns 0 frame 0 TX packets 4985 bytes 325465 (325.4 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0
5、测试网络
root@utuntu01:/home# ping -c 3 www.baidu.com ## 没有问题 PING www.a.shifen.com (39.156.66.18) 56(84) bytes of data. 64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=1 ttl=51 time=18.2 ms 64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=2 ttl=51 time=18.1 ms 64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=3 ttl=51 time=18.2 ms --- www.a.shifen.com ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2004ms rtt min/avg/max/mdev = 18.086/18.166/18.215/0.057 ms
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律