- 查看网卡设备
sudo ifconfig
这里假设我的网卡设备是 eth0 和 eth1
- 打开配置文件
sudo vi /etc/network/interfaces
- 向配置文件添加如下内容
auto eth0
iface eth0 inet static
address 192.168.100.2
netmask 255.255.255.0
auto eth1
iface eth1 inet static
address 192.168.100.3
netmask 255.255.255.0
- 保存并退出
Esc
:wq
- 重启网络服务
sudo systemctl restart networking
- 确认ip已生效
sudo ifconfig
完成。
Linux命令行设置静态IP:网卡配置与重启网络服务
364





