3

I'm trying to alias an ip address onto Lo or create a new loopback interface such as lo:1

I've created /etc/sysconfig/network-scripts/ifcfg-lo:10

DEVICE=lo:10
IPADDR=192.168.10.1
NETMASK=255.255.255.0
NETWORK=192.168.10.0
BROADCAST=192.168.10.255
ONBOOT=yes
NAME=lo10

When I do ifup lo:10

[root@xxxx network-scripts]# ifup lo:10
Error: no device found for connection 'lo10'.

Can anyone please shed some light on this issue. I have used this method for aliasing ip addresses on physical interfaces without issues.

This is not a duplicate as Michael has tried to point out as I'm trying the correctly documented way and would rather not use the rc.local as suggested in what he feels the same question.

4
  • You already have a loopback interface. Why don't you just use it? – Michael Hampton Dec 18 '15 at 18:36
  • @MarkMcN, what if you change the line to NAME=lo:10 or remove the line? – Diamond Dec 18 '15 at 20:11
  • interface lo has the 127.0.0.1 ip address, I need a second lo for a different ip – MarkMcN Dec 18 '15 at 20:45
  • @bangal Tried that and no difference – MarkMcN Dec 18 '15 at 21:13
2

The only way I have been able to get this to work is to issue a

systemctl network restart

Then you get this

ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet 192.168.11.1/24 brd 192.168.11.255 scope global lo0:10

You can though just add an IP address to lo nd you don't need to create a new interface to do it.

ip addr add 192.168.12.1/24 dev lo 

and you get this

    inet 192.168.12.1/24 scope global lo
   valid_lft forever preferred_lft forever

On CentOS the ifup script contains this snipet

if [ -x /sbin/ifup-local ]; then
    /sbin/ifup-local ${DEVICE}
fi

So you can create a file called /etc/sysconfig/network-scripts/ifup-local and have it do things for you once the interface is up

#!/bin/sh
if [[ "$1" == "lo" ]]
then
  ip addr add 192.168.2.1/24 dev lo
else
  # do something else  
fi

Not the answer you're looking for? Browse other questions tagged or ask your own question.