Ubuntu18.04修改IP地址

一、查看并修改IP地址

Ubuntu 18.04使用netplan配置网络,其配置文件是yaml格式的。安装好Ubuntu 18.04之后,在/etc/netplan/目录下默认的配置文件名是00-installer-config.yaml,我们通过VIM修改它:

# ifconfig 
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.56.11  netmask 255.255.255.0  broadcast 192.168.56.255
        inet6 fe80::20c:29ff:feee:97bf  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:ee:97:bf  txqueuelen 1000  (Ethernet)
        RX packets 5431  bytes 465128 (465.1 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3321  bytes 411063 (411.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

# cat /etc/netplan/00-installer-config.yaml 
# This is the network config written by 'subiquity'
network:
  ethernets:
    ens33:
      dhcp4: no
      addresses: [192.168.56.11/24]
      gateway4: 192.168.56.2
      nameservers:
        addresses: [114.114.114.114]    # dns地址
  version: 2


# netplan apply   # 使配置文件生效

 

posted @ 2021-10-04 14:28  林中龙虾  阅读(3121)  评论(0编辑  收藏  举报