Preparation
- ifconfig 查看网络端口号 (下面以eno1为例)
临时配置(重启网络或电脑失效)
# 设置ip别名为eno1:0, 并指定address和netmask
# xxx可以是网段内任意没有被占用的ip
ifconfig eno1:0 192.168.30.xxx netmask 255.255.255.0
永久配置
- 更改/etc/network下interfaces文件如下
# lo配置
auto lo
iface lo inet loopback
# eno1配置
auto eno1
iface eno1 inet dhcp
# eno1:0配置
auto eno1:0
iface eno1:0 inet static
address 192.168.30.xxx
netmask 255.255.255.0
- 重启网络服务
sudo /etc/init.d/networking restart
- 查看是否生效
ifconfig