Debian系统修改绑定IP地址的方法

云服务器

Debian系统修改绑定IP地址的方法

2024-08-11 15:05


                                            




Debian系统使用/etc/network/interfaces文件来配置网卡,通过修改这个文件可以实现IP地址的绑定,此文章主要介绍Debian系统绑定ipv4地址。

首先通过ssh登录系统(root权限):

sudo nano /etc/network/interfaces

写入以下配置:

auto eth0
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1

 

其中含义:

auto eth0 自动激活网卡,其中eth0代表网络接口名称。

iface eth0 inet static 表示静态IP配置。

address 要分配的静态IP地址。

netmask 子网掩码。

gateway 默认网关。

 

保存后重启网络:

sudo /etc/init.d/networking restart
或
sudo service networking restart