ubuntu16 和ubuntu18安装及设置静态ip

1、准备ubuntu16镜像
2、安装:https://zhuanlan.zhihu.com/p/144704865
3、安装ubuntu后,sudo passwd root这个命令建立root用户的密码
4、更新apt-get:apt-get -y update
5、设置静态ip:
    5.1、ifconfig查看网卡名称
    5.2、修改网卡配置文件sudo  vim /etc/network/interfaces
        # auto ens33
        # iface ens33 inet dhcp
        auto ens33
        iface ens33 inet static
        address 192.168.0.10
        netmask 255.255.255.0
        gateway 192.168.0.1
    5.3、修改NDS配置
        sudo vim /etc/resolvconf/resolv.conf.d/head
            nameserver 8.8.8.8
    5.4、重启网络服务 $ sudo /etc/init.d/networking restart
    5.5、重启
    5.6、(可选)安装ssh:sudo apt-get install openssh-server






1、准备ubuntu18镜像
2、安装:https://zhuanlan.zhihu.com/p/144704865
3、安装ubuntu后,sudo passwd root这个命令建立root用户的密码
4、更新apt-get:apt-get -y update
apt-get install net-tools
5、设置静态ip:
    5.1、ifconfig查看网卡名称
    5.2、修改网卡配置文件vim /etc/netplan/01.....
        network:
        version: 2
        renderer: NetworkManager
        ethernets:
         enp3s0: #配置的网卡名称,使用ifconfig -a查看得到
           dhcp4: no #dhcp4关闭
           addresses: [192.168.0.10/24] #设置本机IP及掩码
           gateway4: 192.168.0.1 #设置网关
           nameservers:
             addresses: [8.8.8.8] #设置DNS
    5.3、静态ip生效
        sudo netplan apply
    5.4、解决resolv.conf配置文件被覆盖
        apt-get install resolvconf
        cd /etc/resolvconf/resolv.conf.d/
        vim base
        添加:
            nameserver 8.8.8.8
            nameserver 8.8.4.4
        reboot

原文地址:https://www.cnblogs.com/yangyangming/p/15673222.html