Thursday 29 December 2016

Re: Using the dummy0 interface for a local-only service to be broadcasted by Avahi

On Thu, Dec 29, 2016 at 01:46:30PM -0200, Till Kamppeter wrote:
> On 12/29/2016 01:12 PM, Stéphane Graber wrote:
> > On Thu, Dec 29, 2016 at 01:02:29PM -0200, Till Kamppeter wrote:
> > > Is there no way to dynamically (with checking what is currently in use)
> > > select a small free IPv4 address space? For example in the 10.0.0.0/8 range
> > > there are probably only some 10.X.Y.0/24 subranges used. If not, which IPv6
> > > range is free for such a dummy0 interface? As it is local only and current
> > > Linux supports IPv6 by default it would be no problem to be IPv6-only. It
> > > would also need a host name as IPv6 IP addresses are awkward.
> >
> > There is no way to do so for IPv4 as even if you check your local
> > interfaces and routing tables, you can't know what subnets are hidden
> > behind your router.
> >
>
> Are addresses in the 169.254.0.0/16 not suitable?

It's not suitable because the whole 169.254.0.0/16 subnet is typically
routed to your primary network device. Having a second route for it or a
route for a subset of it on another device would effectively mask part
of it.

>
> > For IPv6, you can generate a random ULA subnet which is near guaranteed
> > to be unique and conflict free.
> >
>
> How does one do this? Which interface will it use, can I Bonjour-broadcast
> it only on the local machine?

ip -6 addr add fd00:xxxx:xxxx:xxxx::1/64 where all the x's are random
values should be fine. There are more officially documented ways to come
up with a 48bit or 64bit ULA subnet mentioned in the various RFCs.

>
> > Depending on exactly what you want to do, a link-local IPv6 address may
> > also be a better fit as it then absolutely cannot conflict with
> > anything.
> >
>
> Also how does one do this? Which interface will it use, can I
> Bonjour-broadcast it only on the local machine?

Every network interface with IPv6 enabled comes up with one, those are the
fe80::/64 subnets you see on your machine.

The loopback device doesn't have one, but a dummy device would.

>
> > > > Making avahi work on 'lo' certainly sounds even nicer.
> > > >
> > >
> > > Would this be very complicated (would need upstream work on Avahi probably)?
> > > It is said that multicast is needed and "lo" does not support multicast. Is
> > > that true?
> >
> > I sure wouldn't recommend using "dummy0". Using a differently named
> > device using the dummy driver would probably be fine though.
> >
> > The reason to stay away from the "dummy0" name is that it's used in test
> > suites and other networking tools that simply call to "ip link add
> > dummy" and then (and that's the problem), call "ip link del dummy"
> > afterwards.
> >
>
> How can I assign a different name to a dummy interface? Can I freely choose
> a name somehow, for example "ippusbxd"? Or have I to use "dummy1", "dummy2",
> ... (loading the dummy kernel module with an option to support more than one
> interface)?

root@castiana:~# ip link add ippusbxd type dummy
root@castiana:~# ip link set ippusbxd up
root@castiana:~# ifconfig ippusbxd
ippusbxd: flags=195<UP,BROADCAST,RUNNING,NOARP> mtu 1500
inet6 fe80::3004:2dff:feb6:b5c7 prefixlen 64 scopeid 0x20<link>
ether 32:04:2d:b6:b5:c7 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2 bytes 140 (140.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


Which gets you your own dummy device with its IPv6 link-local address.

>
> Till
>

--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com