How to create a loopback interface in OpenWrt?

I want to create a loopback interface with this IP 10.10.10.10/32
can anyone tell me how to create the same?

uci set network.loop=interface
uci set network.loop.ifname='lo'
uci set network.loop.proto='static'
uci add_list network.loop.ipaddr='10.10.10.10/32'
uci commit network
service network restart
1 Like

Alternatively, reuse the existing loopback interface:

uci delete network.loopback.ipaddr
uci delete network.loopback.netmask
uci add_list network.loopback.ipaddr=127.0.0.1/8
uci add_list network.loopback.ipaddr=10.10.10.10/32
uci commit network
ifup loopback
1 Like

root@OpenWrt:~# ifconfig
br-lan    Link encap:Ethernet  HWaddr 08:00:27:5B:B0:91
          inet addr:192.168.120.10  Bcast:192.168.120.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe5b:b091/64 Scope:Link
          inet6 addr: fde2:51d1:8b59::1/60 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:112 errors:0 dropped:0 overruns:0 frame:0
          TX packets:21 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:18243 (17.8 KiB)  TX bytes:2770 (2.7 KiB)

eth0      Link encap:Ethernet  HWaddr 08:00:27:5B:B0:91
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:150 errors:0 dropped:0 overruns:0 frame:0
          collisions:0 txqueuelen:1000
          RX bytes:39082 (38.1 KiB)  TX bytes:16254 (15.8 KiB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:7F:0B:AE
          inet addr:192.168.43.10  Bcast:192.168.43.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe7f:bae/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:146 errors:0 dropped:0 overruns:0 frame:0
          TX packets:62 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:15226 (14.8 KiB)  TX bytes:4572 (4.4 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:100 errors:0 dropped:0 overruns:0 frame:0
          TX packets:100 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:10669 (10.4 KiB)  TX bytes:10669 (10.4 KiB)

not showing 10.10.10.10/32 in lo

ping 10.10.10.10
and
ifstatus loop

1 Like
root@OpenWrt:~# ifstatus loop
{
        "up": true,
        "pending": false,
        "available": true,
        "autostart": true,
        "dynamic": false,
        "uptime": 260,
        "l3_device": "lo",
        "proto": "static",
        "device": "lo",
        "updated": [
                "addresses"
        ],
        "metric": 0,
        "dns_metric": 0,
        "delegation": true,
        "ipv4-address": [
                {
                        "address": "10.10.10.10",
                        "mask": 32
                }
        ],
        "ipv6-address": [

        ],
        "ipv6-prefix": [

        ],
        "ipv6-prefix-assignment": [

        ],
        "route": [

        ],
        "dns-server": [

        ],
        "dns-search": [

        ],
        "neighbors": [

        ],
        "inactive": {
                "ipv4-address": [

                ],
                "ipv6-address": [

                ],
                "route": [

                ],
                "dns-server": [

                ],
                "dns-search": [

                ],
                "neighbors": [

                ]
        },
        "data": {

        }
}
root@OpenWrt:~#

root@OpenWrt:~# ping 10.10.10.10
PING 10.10.10.10 (10.10.10.10): 56 data bytes
64 bytes from 10.10.10.10: seq=0 ttl=64 time=0.214 ms
64 bytes from 10.10.10.10: seq=1 ttl=64 time=0.136 ms
64 bytes from 10.10.10.10: seq=2 ttl=64 time=0.176 ms
64 bytes from 10.10.10.10: seq=3 ttl=64 time=0.136 ms
^C
--- 10.10.10.10 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 0.136/0.165/0.214 ms
root@OpenWrt:~#

Works fine.

1 Like


why rx and tx is zero after pinging

Busybox ifconfig only shows the primary IPv4 address of an interface. Use ip -4 addr show dev lo.

2 Likes