alias = „virtual network card“ = you can have multiple ip-addresses per phyisical network card.

under linux the naming is: eth0:0, eth0:1, eth0:2…

those are basically „virtual network cards“ each having their own unique ip-address (may not conflict/collide, not possible to have same ip assigned to two aliases)

service network restart; # centos/suse - reset network
service networking restart; # debian/ubuntu - reset network

route; # show the current routing table

Target/Zielnetzwerk  Router/Gateway  Genmask         Flags Metric Ref    Use Iface
default              172.20.0.1      0.0.0.0         UG    0      0        0 eth0
172.20.0.0           *               255.255.0.0     U     0      0        0 eth0

ifconfig; # show interfaces
eth0      Link encap:Ethernet  Hardware Adresse 00:15:5D:00:07:09
          inet Adresse:172.20.0.25  Bcast:172.20.255.255  Maske:255.255.0.0
...
lo        Link encap:Lokale Schleife
          inet Adresse:127.0.0.1  Maske:255.0.0.0
...

ifconfig eth0:0 192.168.2.40; # create new "virtual network card" = alias
ip addr add 192.168.2.40/24 dev eth0 brd + label eth0:0; # exactly the same but with alternative command ip

ifconfig
eth0      Link encap:Ethernet  Hardware Adresse 00:15:5D:00:07:09
          inet Adresse:172.20.0.25  Bcast:172.20.255.255  Maske:255.255.0.0
...
eth0:0    Link encap:Ethernet  Hardware Adresse 00:15:5D:00:07:09 <- new virtual device added
          inet Adresse:192.168.2.40  Bcast:192.168.2.255  Maske:255.255.255.0
...
lo        Link encap:Lokale Schleife
          inet Adresse:127.0.0.1  Maske:255.0.0.0
...

ifconfig eth0:1 192.168.2.40; # create new "virtual network card" = alias, with same ip, is not allowed
SIOCSIFADDR: Die Datei existiert bereits
SIOCSIFFLAGS: Die angeforderte Adresse kann nicht zugewiesen werden

route add -net 192.168.1.0 netmask 255.255.255.0 dev eth0; # tell computer that it can reach 1.XXX subnet via device eth0
# you do not have to have an ip (alias) asigned to your local network card in the segment 192.168.1.XXX to reach that network
# but you will have to have a route ;)

route
Kernel IP Routentabelle
Ziel            Router          Genmask         Flags Metric Ref    Use Iface
default         172.20.0.1      0.0.0.0         UG    0      0        0 eth0
172.20.0.0      *               255.255.0.0     U     0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0 <- was newly added to table

route add -net 192.168.2.0 netmask 255.255.255.0 dev eth0:0; # tell computer that it can reach 2.XXX subnet via device eth0:0

route
Kernel IP Routentabelle
Ziel            Router          Genmask         Flags Metric Ref    Use Iface
default         172.20.0.1      0.0.0.0         UG    0      0        0 eth0
172.20.0.0      *               255.255.0.0     U     0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0
192.168.2.0     *               255.255.255.0   U     0      0        0 eth0
192.168.2.0     *               255.255.255.0   U     0      0        0 eth0 <- was newly added to table

route add -host 112.22.3.4 dev ppp0; # tell computer that can reach host with ip 112.22.3.4 via ppp0 (modem)
# will give an error if device does not exist

route add -host 112.22.3.4 dev eth0; # tell computer that can reach host with ip 112.22.3.4 via eth0

route
Kernel IP Routentabelle
Ziel            Router          Genmask         Flags Metric Ref    Use Iface
default         172.20.0.1      0.0.0.0         UG    0      0        0 eth0
112.22.3.4      *               255.255.255.255 UH    0      0        0 eth0 <- was newly added to table
172.20.0.0      *               255.255.0.0     U     0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0
192.168.2.0     *               255.255.255.0   U     0      0        0 eth0
192.168.2.0     *               255.255.255.0   U     0      0        0 eth0

route add default gw 192.168.1.1; # add new default gateway (how to reach all other subnets - not explicitly named in the local routing table)

route
Kernel IP Routentabelle
Ziel            Router          Genmask         Flags Metric Ref    Use Iface
default         192.168.1.1     0.0.0.0         UG    0      0        0 eth0 <- was newly added to table
default         172.20.0.1      0.0.0.0         UG    0      0        0 eth0
112.22.3.4      *               255.255.255.255 UH    0      0        0 eth0
172.20.0.0      *               255.255.0.0     U     0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0
192.168.2.0     *               255.255.255.0   U     0      0        0 eth0
192.168.2.0     *               255.255.255.0   U     0      0        0 eth0

route del default; # delete last added default gateway
route
Kernel IP Routentabelle
Ziel            Router          Genmask         Flags Metric Ref    Use Iface
default         172.20.0.1      0.0.0.0         UG    0      0        0 eth0
112.22.3.4      *               255.255.255.255 UH    0      0        0 eth0
172.20.0.0      *               255.255.0.0     U     0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0
192.168.2.0     *               255.255.255.0   U     0      0        0 eth0
192.168.2.0     *               255.255.255.0   U     0      0        0 eth0

route del -net 192.168.2.0 netmask 255.255.255.0; # delete specific route (one has two routes of that kind)

route
Kernel IP Routentabelle
Ziel            Router          Genmask         Flags Metric Ref    Use Iface
default         172.20.0.1      0.0.0.0         UG    0      0        0 eth0
112.22.3.4      *               255.255.255.255 UH    0      0        0 eth0
172.20.0.0      *               255.255.0.0     U     0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0
192.168.2.0     *               255.255.255.0   U     0      0        0 eth0

route del -net 192.168.2.0 netmask 255.255.255.0; # delete specific route (one has one route of that kind)

route
Kernel IP Routentabelle
Ziel            Router          Genmask         Flags Metric Ref    Use Iface
default         172.20.0.1      0.0.0.0         UG    0      0        0 eth0
112.22.3.4      *               255.255.255.255 UH    0      0        0 eth0
172.20.0.0      *               255.255.0.0     U     0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0

route del -net 192.168.2.0 netmask 255.255.255.0; # delete specific route (one has deleted all routes of that kind)
SIOCDELRT: Kein passender Prozess gefunden -> hence the error message

ifconfig eth0:0 down; # remove "virtual network card" = alias

have phun! get your traffic through 😉 may the source and the routing-table be with you!

admin