作者:AngryFox 分类: Uncategorized June 5th, 2018 暂无评论

批量生成
# !/bin/bash
for ((i=3;i<=255;i=i+1))
do
echo "auto eno2:$i">>/root/x.text
echo “iface eno2:$i inet static”>>/root/x.text
echo “address 156.233.42.$i”>>/root/x.text
echo “netmask 255.255.255.0″>>/root/x.text
echo ” “>>/root/x.text
done
# end

第二种方法:修改网卡配置文件

在ubuntu下,网卡的配置文件是/etc/network/interfaces,所以我们修改它:

sudo gedit /etc/network/interfaces

照eth0添加eth0:0

auto eth0
iface eth0 inet static
name Ethernet Lan card
address 192.168.1.2
netmask 255.255.255.0
network 192.168.1.1
broadcast 192.168.1.255
gateway 192.168.1.254

auto eth0:0
iface eth0:0 inet static
name Ethernet Lan card
address 192.168.1.3
netmask 255.255.255.0
network 192.168.1.1
broadcast 192.168.1.255
gateway 192.168.1.254

然后重启服务

sudo /etc/init.d/networking restart

测试新的ip地址

ping 192.168.1.2
ping 192.168.1.3