ubuntu server固定ip


ubuntu server固定ip

Ubuntu 18.04.5 LTS ubuntu 重启之后ip 会重新分配需要固定ip 方便连接

第一步 获取网卡名

ifconfig

eno1

image-20220224093154594

第二步 更改配置文件

sudo vi /etc/network/interfaces

# 根据2网卡名填入
auto eno1
    iface eno1 inet static
    address 192.168.1.137 # 需要固定的ip
    netmask 255.255.255.0
    gateway 192.168.1.1
    iface eno1 inet6 auto

第二步 刷新配置并重启网卡

resolvconf -u

/etc/init.d/networking restart