ubuntu 不同版本 ip地址配置
Ubuntu14.04或者Ubuntu16.04 静态ip 配置
编辑配置文件vi /etc/network/interfaces
auto ens33 #网卡名 iface ens33 inet static #设置为静态 address 192.168.0.13 #IP地址 netmask 255.255.255.0 #子网掩码 gateway 192.168.0.1 #网关 dns-nameserver 114.114.114.114 #DNS服务器
dns-nameserver 8.8.8.8 #DNS服务器
sudo /etc/init.d/networking restart 或者 systemctl rstart netowrking
ubuntu18.04 或者 20.04静态ip 配置
bestseller@ubuntu1804:/etc/netplan$ pwd /etc/netplan bestseller@ubuntu1804:/etc/netplan$ ls 50-cloud-init.yaml 50-cloud-init.yaml.bak bestseller@ubuntu1804:/etc/netplan$ cat 50-cloud-init.yaml # This file is generated from information provided by # the datasource. Changes to it will not persist across an instance. # To disable cloud-init's network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} network: ethernets: ens160:
dhcp4:no addresses: - 192.168.1.100/24 gateway4: 192.168.1.254 nameservers: addresses: - 8.8.8.8 search: - 114.114.114.114 version: 2
更新配置
sudo netplan apply