Но меня больше интересовал вопрос (как-то давно не пересекался): что произойдёт с таблицей роутинга при навешивании таких алиасных IP.
Проверяем:
Код: Выделить всё
bash-4.2$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.5 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::215:60ff:fec4:ee02 prefixlen 64 scopeid 0x20<link>
ether 00:15:60:c4:ee:02 txqueuelen 1000 (Ethernet)
RX packets 129985 bytes 97106629 (92.6 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 123992 bytes 17131967 (16.3 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 16
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 16436
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 706 bytes 20698 (20.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 706 bytes 20698 (20.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Это до.
Код: Выделить всё
bash-4.2$ sudo ifconfig eth0:0 192.168.2.5/24
bash-4.2$ sudo ifconfig eth0:1 192.168.3.5/24
Код: Выделить всё
bash-4.2$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.5 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::215:60ff:fec4:ee02 prefixlen 64 scopeid 0x20<link>
ether 00:15:60:c4:ee:02 txqueuelen 1000 (Ethernet)
RX packets 130451 bytes 97286082 (92.7 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 124560 bytes 17224068 (16.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 16
eth0:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.2.5 netmask 255.255.255.0 broadcast 192.168.2.255
ether 00:15:60:c4:ee:02 txqueuelen 1000 (Ethernet)
device interrupt 16
eth0:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.3.5 netmask 255.255.255.0 broadcast 192.168.3.255
ether 00:15:60:c4:ee:02 txqueuelen 1000 (Ethernet)
device interrupt 16
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 16436
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 761 bytes 22293 (21.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 761 bytes 22293 (21.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Роутинг:
Код: Выделить всё
bash-4.2$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.3.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0