Loopback interfaces in LEDE

Hi, I've managed all sorts of network devices over the years, and have frequently made use of loopback interfaces to which to bind services.

On a multihomed device such as a router, these have the benefits of being 'always up', and also of providing a single consistent address (with forward and reverse name resolution) for configuring services such as NTP, syslog and so on.

In LEDE, what is the 'correct' way of defining custom loopback interfaces, so that they are visible to the routing table and can be used in the way described above ?

Tia, AJM

Interfaces are defined in /etc/config/network

play around with creating additional interfaces/VLANs on the lan interface
through the GUI and look at the resulting file. You should then be able to do
the same with the lo interface.

It works pretty much the same way as any other linux system, just with
syntactical differences, see https://wiki.openwrt.org/doc/uci/network for some
of the syntax details

David Lang

Thanks, thankfully it wasn't hard, I just used an interface alias to create a second loopback:

config interface 'self'
    option ifname 'lo'
    option proto 'static'
    option ipaddr '10.0.4.1 10.0.4.2 10.0.4.3 10.0.4.4'
    option netmask '255.255.255.255'
    option ip6assign '60'

This will do for now, though will need tidying as I get round to running everything dual stack.

Next job is to figure out how to actually bind some key services (eg. syslog) to the desired addresses, and persuade dnsmasq into providing forward and reverse name resolution..

One problem is that luci replaces "lo" with another name such as "eth0" if you apply any changes to the interface. Which can be a bad surprise if you don't know.

Try using option ifname @loopback instead.

1 Like