Alias in openWrt

Previous openWrt versions, for example backfire, supported alias creation by means of the file /etc/config/network. The whole mechanism of initialization was realized on the base of configuration scripts which were started at system start. Now the demon named netifd is responsible for all this.

Based upon comments to commits the alias support was added from the configuration file /etc/config/network starting from the commit from 2011-10-18.

There is an example of the file /etc/config/network in openWrt for alias creation:

config interface 'loopback'
	option ifname 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

config interface 'lan'
	option ifname 'eth0.1'
	option proto 'static'
	option ipaddr '192.168.1.1'
	option netmask '255.255.255.0'

config alias
	option interface lan
	option proto 'static'
	option ipaddr '10.0.0.1'
	option netmask '255.255.255.0'

Alias is created, but created somehow not standardly. By the command ifconfig one can see the second interface, but can't see the ip address on it.

eth0      Link encap:Ethernet  HWaddr 08:00:27:FE:9C:0F
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:402 (402.0 B)

eth0.1    Link encap:Ethernet  HWaddr 08:00:27:FE:9C:0F
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:402 (402.0 B)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:14832 errors:0 dropped:0 overruns:0 frame:0
          TX packets:14832 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1008576 (984.9 KiB)  TX bytes:1008576 (984.9 KiB)

The utility ip can help us in it. The output ip addr shows the alias and its ip address.

1: lo:  mtu 16436 qdisc noqueue
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
2: eth0:  mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 08:00:27:fe:9c:0f brd ff:ff:ff:ff:ff:ff
3: eth0.1@eth0:  mtu 1500 qdisc noqueue
    link/ether 08:00:27:fe:9c:0f brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.1/24 brd 192.168.1.255 scope global eth0.1
    inet 10.0.0.1/24 brd 10.0.0.255 scope global eth0.1