avatar
童琦杰
Mar 11, 2022Technology

Ubuntu设置静态IP

Ubuntu 16.04

bash
vim /etc/network/interfaces

修改配置文件

/etc/network/interfaces
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.200    # local IP Address
gateway 192.168.0.1
netmask 255.255.255.0
dns-nameservers 8.8.8.8  # specify dns server

Ubuntu 18.04

bash
vim /etc/netplan/50-cloud-init.yaml 

修改配置文件

/etc/netplan/50-cloud-init.yaml
yaml
network:
  ethernets:
    eth0:
      dhcp4: false
      addresses: [192.168.0.200/24]
      gateway4: 192.168.0.1
      nameservers:
        addresses: [8.8.8.8]
© 2015-2022 tongqijie.com 版权所有沪ICP备17000682号