ubuntu18.04_server配置静态IPv4

2022/4/29 7:16:06

本文主要是介绍ubuntu18.04_server配置静态IPv4,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

ifconfig
返回如下:
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.19  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::a00:27ff:fe48:cd59  prefixlen 64  scopeid 0x20<link>
        inet6 2408:8207:7899:3330:a00:27ff:fe48:cd59  prefixlen 64  scopeid 0x0<global>
        ether 08:00:27:48:cd:59  txqueuelen 1000  (Ethernet)
        RX packets 7388  bytes 10431679 (10.4 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1812  bytes 185665 (185.6 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
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 120  bytes 9880 (9.8 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 120  bytes 9880 (9.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

sudo vim /etc/netplan/*.yaml
编辑enp0s3这块网卡的yaml

vim内容如下

network:
  ethernets:
    enp0s3:
      dhcp4: false
      addresses: [192.168.1.19/24]
      gateway4: 192.168.1.1
      nameservers:
              addresses: [119.29.29.29]
  version: 2
sudo netplan
ifconfig 查看是否修改成功


这篇关于ubuntu18.04_server配置静态IPv4的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程