以前にOS X で NIC に複数の IP アドレスを割り当てるにはという記事を書きました。Ubuntu でひとつの NIC に複数の IP アドレスを割り当てるには /etc/network/interfaces を以下のように書きます。
auto ens160 iface ens160 inet static address 192.168.1.100 netmask 255.255.255.0 gateway 192.168.1.254 dns-nameservers 8.8.8.8 8.8.4.4 auto ens160:1 iface ens160:1 inet static address 192.168.1.101 netmask 255.255.255.0 auto ens160:2 iface ens160:2 inet static address 192.168.1.102 netmask 255.255.255.0 auto ens160:3 iface ens160:3 inet static address 192.168.1.103 netmask 255.255.255.0
これで以下のようになりました。
インターフェイス名 | アドレス |
---|---|
ens160 | 192.168.1.100 |
ens160:1 | 192.168.1.101 |
ens160:2 | 192.168.1.102 |
ens160:3 | 192.168.1.103 |