ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

ubuntu 20.04中配置静态IP

2022-05-02 02:31:44  阅读:248  来源: 互联网

标签:66.18 IP time bytes 64 ms ubuntu 39.156 20.04


 

1、系统

root@liujiaxinpc1:/home/test# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.4 LTS
Release:        20.04
Codename:       focal

 

2、查看网卡名称

root@liujiaxinpc1:/home/test# netstat -i
Kernel Interface table
Iface      MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
ens32     1500    48091      0      0 0          8458      0      0      0 BMRU
lo       65536      224      0      0 0           224      0      0      0 LRU

 

3、修改网络配置文件,保存退出

# This is the network config written by 'subiquity'??? 这个格式贼难调, 可以直接复制这个模板
network:
 ethernets:
  ens32:                       ## 网卡名称
   addresses:
   - 192.168.3.50/24           ## ip地址
   gateway4: 192.168.3.1       ## 网关
   nameservers:
    addresses:
    - 119.29.29.29             ## DNS服务
 version: 2

 

 

4、将网络模式调整为桥接模式

 

 

 

 

5、重启网络服务(如果出现报错,一般是网络配置文件格式的问题)

root@liujiaxinpc1:~/Desktop# netplan apply

 

6、查看ip

root@liujiaxinpc1:~/Desktop# ifconfig | head
ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.3.50  netmask 255.255.255.0  broadcast 192.168.3.255
        inet6 fe80::1a8b:1520:347d:bea9  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:ed:73:9d  txqueuelen 1000  (Ethernet)
        RX packets 49372  bytes 68621721 (68.6 MB)
        RX errors 0  dropped 239  overruns 0  frame 0
        TX packets 8854  bytes 653029 (653.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

 

7、测试网络

root@liujiaxinpc1:~/Desktop# ping -c 5 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=17.8 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=2 ttl=51 time=18.2 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=3 ttl=51 time=17.7 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=4 ttl=51 time=17.8 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=5 ttl=51 time=18.0 ms

--- www.a.shifen.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4007ms
rtt min/avg/max/mdev = 17.713/17.907/18.166/0.164 ms

 

8、重启观察IP是否发生变化

root@liujiaxinpc1:~/Desktop# reboot

 

9、查看ip,检查网络连接

root@liujiaxinpc1:~/Desktop# ifconfig | head -n 5
ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.3.50  netmask 255.255.255.0  broadcast 192.168.3.255
        inet6 fe80::20c:29ff:feed:739d  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:ed:73:9d  txqueuelen 1000  (Ethernet)
        RX packets 40  bytes 2791 (2.7 KB)
root@liujiaxinpc1:~/Desktop# ping -c 5 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=17.8 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=2 ttl=51 time=17.8 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=3 ttl=51 time=17.9 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=4 ttl=51 time=17.7 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=5 ttl=51 time=17.8 ms

--- www.a.shifen.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4009ms
rtt min/avg/max/mdev = 17.718/17.804/17.893/0.055 ms

没有问题。

 

标签:66.18,IP,time,bytes,64,ms,ubuntu,39.156,20.04
来源: https://www.cnblogs.com/liujiaxin2018/p/16214940.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有