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 查看是否修改成功
posted @ 2022-04-28 09:54  烧刘病  阅读(182)  评论(0编辑  收藏  举报
回到页首