ubuntu19.04配置静态IP

ubuntu19.04配置静态IP

要在Ubuntu 19.04服务器上配置static静态IP地址,需要修改netplan网络配置文件/etc/netplan/。

修改netplan配置文件

cp /etc/netplan/50-cloud-init.yaml{,.bak}

cat > /etc/netplan/50-cloud-init.yam << EOF
network:
  version: 2
  renderer: networkd
  ethernets:
    enp3s0:
      addresses:
        - 192.168.93.6/24
      gateway4: 92.168.93.2
      nameservers:
          addresses: [8.8.8.8, 8.8.4.4]
EOF          

应用网络配置

root@ubuntu:~# netplan apply

验证配置

root@ubuntu:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:4c:e3:83 brd ff:ff:ff:ff:ff:ff
    inet 192.168.93.6/24 brd 192.168.93.255 scope global ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe4c:e383/64 scope link 
       valid_lft forever preferred_lft forever

参考:https://netplan.io/examples

你可能感兴趣的:(linux,Linux)