查看: 73|回覆: 0

[Ubuntu] ubuntu 20.04配置网络

[複製鏈接]

2

主題

0

回帖

0

積分

热心网友

金币
0
閲讀權限
220
精華
0
威望
0
贡献
0
在線時間
0 小時
註冊時間
2011-12-4
發表於 2022-3-25 12:20:00 | 顯示全部樓層 |閲讀模式

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

 



来源:https://www.cnblogs.com/liujiaxin2018/p/16054067.html
回覆

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即注册

本版積分規則

相关侵权、举报、投诉及建议等,请发 E-mail:qiongdian@foxmail.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部