ipv6 ::1 and lo dev

5 messages, 4 authors, 2021-08-19 · open the first message on its own page

ipv6 ::1 and lo dev

From: Oleg <hidden>
Date: 2021-08-18 17:06:49

  Hello.

I try to replace ::1/128 ipv6 address on lo dev with ::1/112 to
access more than 1 address(like with ipv4 127.0.0.1/8). But i get
worked only address which is set on the dev. For example:

~# ip a show dev lo
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
~# ping -c1 -w1 127.0.0.2
PING 127.0.0.2 (127.0.0.2) 56(84) bytes of data.
64 bytes from 127.0.0.2: icmp_seq=1 ttl=64 time=0.095 ms
--- 127.0.0.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.095/0.095/0.095/0.000 ms

~# ping -c1 -w1 ::2
PING ::2(::2) 56 data bytes
--- ::2 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms

Replace ::1/128 with ::1/112 and try again:

~# ip -6 a flush dev lo
~# ip -6 a add dev lo local ::1/112 scope host
~# ip a show dev lo
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/112 scope host 
       valid_lft forever preferred_lft forever
~# ping -c1 -w1 ::2
PING ::2(::2) 56 data bytes
--- ::2 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms

So, this don't work. How can i get the same behaviour for ipv6
loopback addresses as with ipv4?

Thanks!

-- 
Олег Неманов (Oleg Nemanov)

Re: ipv6 ::1 and lo dev

From: Thorsten Glaser <hidden>
Date: 2021-08-18 17:47:50

On Wed, 18 Aug 2021, Oleg wrote:
I try to replace ::1/128 ipv6 address on lo dev with ::1/112 to
access more than 1 address(like with ipv4 127.0.0.1/8). But i get
AIUI this is not possible in IPv6, only :: and ::1 are reserved,
the rest of ::/96 is IPv4-compatible IPv6 addresses.

I never understood why you’d want more than one address for loopback
anyway (in my experience, the more addresses a host has, the more
confused it’ll get about which ones to use for what).

bye,
//mirabilos
-- 
Infrastrukturexperte • tarent solutions GmbH
Am Dickobskreuz 10, D-53121 Bonn • http://www.tarent.de/
Telephon +49 228 54881-393 • Fax: +49 228 54881-235
HRB AG Bonn 5168 • USt-ID (VAT): DE122264941
Geschäftsführer: Dr. Stefan Barth, Kai Ebenrett, Boris Esser, Alexander Steeg

*************************************************

Mit dem tarent-Newsletter nichts mehr verpassen: www.tarent.de/newsletter

*************************************************

Re: ipv6 ::1 and lo dev

From: Willy Tarreau <w@1wt.eu>
Date: 2021-08-18 20:18:03

On Wed, Aug 18, 2021 at 07:47:37PM +0200, Thorsten Glaser wrote:
On Wed, 18 Aug 2021, Oleg wrote:
quoted
I try to replace ::1/128 ipv6 address on lo dev with ::1/112 to
access more than 1 address(like with ipv4 127.0.0.1/8). But i get
AIUI this is not possible in IPv6, only :: and ::1 are reserved,
the rest of ::/96 is IPv4-compatible IPv6 addresses.

I never understood why you'd want more than one address for loopback
anyway (in my experience, the more addresses a host has, the more
confused it'll get about which ones to use for what).
It's because you've probably never dealt with massive hosting :-)
Sometimes binding a full /24 (or smaller) on the loopback, be it
for listening addresses or to be used as sources to connect to
next hops, is extremely useful.

Willy

Re: ipv6 ::1 and lo dev

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2021-08-18 21:15:52

On Wed, 18 Aug 2021 22:17:55 +0200
Willy Tarreau [off-list ref] wrote:
On Wed, Aug 18, 2021 at 07:47:37PM +0200, Thorsten Glaser wrote:
quoted
On Wed, 18 Aug 2021, Oleg wrote:
  
quoted
I try to replace ::1/128 ipv6 address on lo dev with ::1/112 to
access more than 1 address(like with ipv4 127.0.0.1/8). But i get  
AIUI this is not possible in IPv6, only :: and ::1 are reserved,
the rest of ::/96 is IPv4-compatible IPv6 addresses.

I never understood why you'd want more than one address for loopback
anyway (in my experience, the more addresses a host has, the more
confused it'll get about which ones to use for what).  
It's because you've probably never dealt with massive hosting :-)
Sometimes binding a full /24 (or smaller) on the loopback, be it
for listening addresses or to be used as sources to connect to
next hops, is extremely useful.

Willy
In the large scale routing world addresses are assigned to loopback
interface because it keeps routing protocols happy. If interface goes
down loopback stays around.

Re: ipv6 ::1 and lo dev

From: Oleg <hidden>
Date: 2021-08-19 09:17:44

On Wed, Aug 18, 2021 at 07:47:37PM +0200, Thorsten Glaser wrote:
On Wed, 18 Aug 2021, Oleg wrote:
quoted
I try to replace ::1/128 ipv6 address on lo dev with ::1/112 to
access more than 1 address(like with ipv4 127.0.0.1/8). But i get
AIUI this is not possible in IPv6, only :: and ::1 are reserved,
the rest of ::/96 is IPv4-compatible IPv6 addresses.
This is a big mistake of standards and, i think, we shouldn't conform to
standards in this area. Because standards conflicts with real life practice
(and needs) here.

I think, we can safely use ::/104 as analog of 127.0.0.1/8, because, AFAIK,
0.0.0.0/8 isn't used now in practice and thus there are no problems with
ipv4-mapped ipv6 addresses.

In any case, we should allow users to get an expected behaviour for lo dev
address - as with 127.0.0.1/8. I.e. when i remove ::1/128 and set ::1/104
i expect that ping ::2, ::3 and etc will work(may be only if some parameter for
"ip a add" is specified).

Unfortunately i can't suggest any patch, because my kernel programming level
is about 0 :-). May be anybody can do it?
I never understood why you’d want more than one address for loopback
anyway (in my experience, the more addresses a host has, the more
confused it’ll get about which ones to use for what).
Besides already mentioned cases i say you about my 2 cases:

1. We have a service which serve many tunnels to different machines
  (think of it as many ssh -R X:127.0.0.N:Y to our service servers). Each
  machine is mapped to address:port(thus it constant between sessions).
  And we use many addresses from 127.0.0.1/8 :-).
2. We have many qemu VMs on several hardware hosts. We assign an address
  to every VM from 127.0.0.1/8 for comfort use of telnet/vnc. E.g. we
  have in /etc/hosts something like this(where third column is for
  host machine index and fourth column is for VM index):

  ...
  127.0.1.2       www1.vm
  127.0.1.3       www2.vm
  127.0.1.4       www3.vm
  127.0.1.5       dns1.vm
  127.0.1.5       dns2.vm
  127.0.1.6       mail1.vm
  ...

  and run qemu with:

  -serial telnet:dns1.vm:23,server,nowait -vnc dns1.vm:0

  This /etc/hosts syncronized between hardware hosts and if one if it fail
  we can migrate all VMs from it to another one and their addresses aren't
  intermixed.

-- 
Олег Неманов (Oleg Nemanov)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help