Difference between revisions of "Enable IPv6"

From MythTV Official Wiki
Jump to: navigation, search
(IPv6 back in service after 9b70915)
(Reworked based on latest 0.25pre fixes)
Line 1: Line 1:
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]
0.25pre {{gitcommit|8bf5157}} allows users the '''option''' of connecting  
+
0.25pre {{gitcommit|37385ba}} allows users the '''option''' of connecting  
to MythTV via IPv6
+
to <code>mythbackend</code> via IPv6 for file transfers.
 +
 
 +
This Wiki shows how to activate IPv6. This is
 +
part of a significant change in the way MythTV binds to sockets.
  
 
==IPv6 Configuration==
 
==IPv6 Configuration==
Line 13: Line 16:
 
Stop all frontends and backends.
 
Stop all frontends and backends.
  
Using <code>mythtv-setup</code> on the Master Backend, go to the General page, enter the
+
Using <code>mythtv-setup</code> on the master backend, go to the General page, enter the
address of choice in the <code>Local Backend IP address:</code> and in the
+
address of choice in the <code>IPv6 address:</code> field.
<code>Master Backend IP address:</code> fields.
 
  
The fields should look like this.
+
The field should look something like this.
 
<pre>
 
<pre>
Local Backend IP address:  fd01:a:b:1::123
+
IPv6 address: fd01:a:b:1::123
Master Backend IP address: fd01:a:b:1::123
 
 
</pre>
 
</pre>
  
Note that addresses aren't enclosed in brackets (<code>[]</code>) nor is there
+
Note that some (non MythTV) programs require their IPv6
a trailing percent sign and Scope ID (<code>%eth0</code>.)
+
addresses enclosed in brackets (<code>[]</code>) or the
 +
addition of a trailing percent sign and Zone Index
 +
(e.g. <code>%eth0</code>.) Neither of these should be used
 +
with MythTV.
  
 
Use <code>mythtv-setup</code> to configure any slave
 
Use <code>mythtv-setup</code> to configure any slave
 
backends with their own IPv6 addresses.
 
backends with their own IPv6 addresses.
  
Restart the backend(s). Frontends will connect to them via IPv6
+
Restart the backend(s). Frontends will now perform file transfers
as they're restarted.
+
(e.g. recording playback) via IPv6.
  
 
==Which IPv6 address should be used?==
 
==Which IPv6 address should be used?==
Line 38: Line 42:
 
within a LAN.
 
within a LAN.
  
[Note that ULAs have bit 8 set and are,
+
Note that even though ULAs are global addresses, no self
therefore, global addresses - no self respecting router
+
respecting router will pass them out on the internet.
will pass these addresses out on the internet.]
 
  
 
Use a search engine and look for: 'Unique Local Address generator'
 
Use a search engine and look for: 'Unique Local Address generator'
to find a site that will create ULAs correctly.
+
to find a site that will create ULAs correctly
 +
([http://http://www.sixxs.net/tools/grh/ula/ for example].)
  
Details on constructing ULAs can be found in
+
For details on constructing ULAs see
 
[http://tools.ietf.org/html/rfc4193#section-3.2.2 RFC 4193].
 
[http://tools.ietf.org/html/rfc4193#section-3.2.2 RFC 4193].
  
MythTV must have a globally routeble (e.g. <code>2001:db8::1</code>) address configured '''only'''
+
MythTV must have a globally routeble IPv6 address (e.g.
if it is necessary to run MythTV from a frontend/slave located outside
+
<code>2001:db8::1</code>) configured '''only''' if it is
of the Master Backend's LAN.
+
necessary to run MythTV from a frontend/slave over the
 +
internet.
  
 
Site Local (<code>fec0::/10</code>) addresses were deprecated in 2004.
 
Site Local (<code>fec0::/10</code>) addresses were deprecated in 2004.
  
Host (::1) and Link Local (<code>fe80::/64</code>) addresses are not
+
Host (::1) addresses are configured in MythTV automatically, but
routable and shouldn't be used.
+
are not routable, use them for a stand alone system.
 +
 
 +
Since all Link Local addresses have the same prefix
 +
(<code>fe80::/10</code>), they require a Zone Index
 +
(e.g. <code>%eth0</code>) for routing and shouldn't
 +
be used. MythTV will automatically ignore these
 +
addresses.
  
 
To list currently assigned IPv6 addresses, type:
 
To list currently assigned IPv6 addresses, type:
Line 86: Line 97:
 
Verify that IPv6 is active on each MythTV host.
 
Verify that IPv6 is active on each MythTV host.
  
If ssh, for example, is known to work, a simple
+
If <code>ssh</code>, for example, is known to work, a simple
test (run from the Master Backend) is:
+
test (run from the master backend) is:
  
 
<pre>
 
<pre>
 
for HOST in <list all frontend and slave backends here>
 
for HOST in <list all frontend and slave backends here>
do  ssh -6 $HOST ls -l /bin/ls
+
do  ssh -6 $HOST hostname
 
done
 
done
 
</pre>
 
</pre>
  
 
If the test works for all frontends and slave backends,
 
If the test works for all frontends and slave backends,
the system is ready for conversion.
+
IPv6 can be added to MythTV.
  
 
If the above fails, see the following section.
 
If the above fails, see the following section.
Line 113: Line 124:
 
</pre>
 
</pre>
  
*If:
+
*Some distributions keep these options in files under <code>/etc/sysctl.d</code>.
<pre>
 
net.ipv6.bindv6only = 1
 
</pre>
 
and IPv6 is active and the MythTV system is sill configured with '''IPv4''' addresses, clients will fail to connect until they are converted to use '''IPv6''' addresses, as IPv4 addresses won't be able to connect to the backend ({{Ticket|9820}}, {{Ticket|9840}} and {{Ticket|10165}}.)
 
 
 
*Some distributions keep these options: <code>/etc/sysctl.d</code>. Look for file names like <code>60-bindv6only.conf</code> for example, and put <code>net.ipv6.bindv6only = 0</code> in it.
 
  
 
*Be sure any firewalls have been adjusted to accept the IPv6 addresses being used.
 
*Be sure any firewalls have been adjusted to accept the IPv6 addresses being used.
  
*MySQL connections are currently selected by the information in config.xml and mysql.txt files. Unless a version of MySQL that supports IPv6 is being used, no changes are required.
+
*MySQL connections are currently selected by the hostname information in config.xml and mysql.txt files. Unless a version of MySQL that supports IPv6 is being used, no changes are required.
  
 
*If there are entries in <code>/etc/hosts</code> (etc.), for both IPv4 and IPv6 addresses that have the same hostname (which is perfectly legal,) make sure the host's preferences pick IPv4 first. <code>/etc/gai.conf</code> may exist and control this.
 
*If there are entries in <code>/etc/hosts</code> (etc.), for both IPv4 and IPv6 addresses that have the same hostname (which is perfectly legal,) make sure the host's preferences pick IPv4 first. <code>/etc/gai.conf</code> may exist and control this.
Line 132: Line 137:
  
 
These examples are all from a host with <code>mythbackend</code>
 
These examples are all from a host with <code>mythbackend</code>
running and using IPv6. MySQL is running and using IPv4.
+
running and IPv6 configured. MySQL is running and using IPv4.
Obviously, they can be run on frontends and slave backends.
+
Obviously, these tools can be run on frontends and slave backends.
  
 
{{Warning box|The output of some tools and in logfiles may expose IPv6 addresses.
 
{{Warning box|The output of some tools and in logfiles may expose IPv6 addresses.
Line 144: Line 149:
 
<code>sudo netstat -pant | egrep '3306|6543'</code>
 
<code>sudo netstat -pant | egrep '3306|6543'</code>
  
When the backend is running, but no frontends are connected, expect:
+
When the backend is running, but no slave backends/frontends are connected, expect:
 
<pre>
 
<pre>
tcp  0 0  0.0.0.0:3306     0.0.0.0:*     LISTEN      1436/mysqld     
+
tcp  0 0  0.0.0.0:3306           0.0.0.0:*     LISTEN      1198/mysqld     
tcp6  0       0 :::6543          :::*     LISTEN      2123/mythbackend
+
tcp  0  0  192.168.1.123:6543      0.0.0.0:*      LISTEN      26961/mythbackend
 +
tcp  0  0  127.0.0.1:6543          0.0.0.0:*      LISTEN      26961/mythbackend
 +
tcp6  0 0 fd01:a:b:1::123:6543   :::*           LISTEN      26961/mythbackend
 +
tcp6  0  0  ::1:6543                :::*           LISTEN      26961/mythbackend
 
</pre>
 
</pre>
 
+
With one frontend connected and playing a recording, expect:
With a frontend connected, expect:
 
 
<pre>
 
<pre>
tcp  0 0 0.0.0.0:3306           0.0.0.0:*           LISTEN      1436/mysqld     
+
tcp  0 0 0.0.0.0:3306           0.0.0.0:*             LISTEN      1384/mysqld     
tcp  0 0 192.168.1.123:3306     192.168.1.200:33878  ESTABLISHED 1436/mysqld     
+
tcp  0 0 192.168.1.123:6543    0.0.0.0:*              LISTEN      26961/mythbackend
...
+
tcp  0  0 127.0.0.1:6543        0.0.0.0:*              LISTEN      26961/mythbackend
tcp6 0 0 :::6543                 :::*                LISTEN      2123/mythbackend
+
tcp  0  0 192.168.1.123:3306     192.168.1.234:56538    ESTABLISHED 1384/mysqld     
tcp6  0 0 fd01:a:b:1::123:6543 fd01:a:b:1::456:35220  ESTABLISHED 2123/mythbackend
+
tcp  0  0 192.168.1.123:3306    192.168.1.234:56601    ESTABLISHED 1384/mysqld   
tcp6  0 0 fd01:a:b:1::123:6543 fd01:a:b:1::456:35219  ESTABLISHED 2123/mythbackend
+
tcp  0 0 192.168.1.123:6543    192.168.1.234:42760    ESTABLISHED 26961/mythbackend
 +
tcp  0  0 192.168.1.123:6543     192.168.1.234:42761    ESTABLISHED 26961/mythbackend
 +
tcp  0  0 192.168.10.204:3306    192.168.1.234:56532    ESTABLISHED 1384/mysqld   
 +
tcp6  0 0 fd01:a:b:1::123:6543   fd01:a:b:1::456:36345  ESTABLISHED 26961/mythbackend
 +
tcp6  0 0 fd01:a:b:1::123:6543   fd01:a:b:1::456:36346  ESTABLISHED 26961/mythbackend
 +
tcp6  0  0 ::1:6543              :::*                  LISTEN      26961/mythbackend
 
</pre>
 
</pre>
  
Line 173: Line 185:
 
</pre>
 
</pre>
  
Port 3306 fails in this test, as expected, because the MySQL version
+
Port 3306 fails in this test, as expected, because the MySQL version used
 
doesn't support IPv6 (remove the <code>-6</code> flag above and this will work.)
 
doesn't support IPv6 (remove the <code>-6</code> flag above and this will work.)
  
As always, both <code>mythbackend</code> and <code>mythfrontend</code>
+
Additional information is available from both <code>mythbackend</code>
can be started with additional logging enabled:
+
and <code>mythfrontend</code> if the <code>--loglevel debug</code> is
 +
used.
  
 
<pre>
 
<pre>
<code>mythbackend --verbose general,network --nodblog --quiet \
+
mythbackend --verbose general --nodblog --quiet \
     --logpath=/var/log/mythtv --loglevel=debug</code>
+
     --logpath /var/log/mythtv --loglevel debug
 
</pre>
 
</pre>
  
A currently running backend's logging can be changed with:
+
A running backend's loglevel can be changed by typing:
  
<code>mythbackend --setverbose network --quiet --nodblog</code>
+
<code>mythbackend --setloglevel debug --quiet --nodblog</code>
  
 
Back to [[#IPv6 Configuration]]
 
Back to [[#IPv6 Configuration]]

Revision as of 14:58, 14 February 2012

0.25pre [37385ba] allows users the option of connecting to mythbackend via IPv6 for file transfers.

This Wiki shows how to activate IPv6. This is part of a significant change in the way MythTV binds to sockets.

IPv6 Configuration

Interfaces typically have multiple IPv6 addresses. For help picking the right one, see #Which IPv6 address should be used?.

If IPv6 is known to be working, just complete the following. Otherwise, see #Prerequsites.

Stop all frontends and backends.

Using mythtv-setup on the master backend, go to the General page, enter the address of choice in the IPv6 address: field.

The field should look something like this.

IPv6 address: fd01:a:b:1::123

Note that some (non MythTV) programs require their IPv6 addresses enclosed in brackets ([]) or the addition of a trailing percent sign and Zone Index (e.g. %eth0.) Neither of these should be used with MythTV.

Use mythtv-setup to configure any slave backends with their own IPv6 addresses.

Restart the backend(s). Frontends will now perform file transfers (e.g. recording playback) via IPv6.

Which IPv6 address should be used?

The most likely choice is a Unique Local Address (ULA.) Use ULA's if all access to the backend will be within a LAN.

Note that even though ULAs are global addresses, no self respecting router will pass them out on the internet.

Use a search engine and look for: 'Unique Local Address generator' to find a site that will create ULAs correctly (for example.)

For details on constructing ULAs see RFC 4193.

MythTV must have a globally routeble IPv6 address (e.g. 2001:db8::1) configured only if it is necessary to run MythTV from a frontend/slave over the internet.

Site Local (fec0::/10) addresses were deprecated in 2004.

Host (::1) addresses are configured in MythTV automatically, but are not routable, use them for a stand alone system.

Since all Link Local addresses have the same prefix (fe80::/10), they require a Zone Index (e.g. %eth0) for routing and shouldn't be used. MythTV will automatically ignore these addresses.

To list currently assigned IPv6 addresses, type: ifconfig ethX | grep inet6

inet6 addr: fe80::222:22ff:fe22:2222/64 Scope:Link
inet6 addr: fd01:a:b:1::123/64 Scope:Global
inet6 addr: 2001:db8::123/64 Scope:Global

In the above, the middle address is probably the best choice. It is also probably one that must be assigned manually.

If the desired address doesn't exist, use the configuration tool provided with the host's distribution to add it.

Entries in /etc/hosts (DHCP, router etc.) are optional. The following is an example for one host:

192.168.1.123              masterbe.local    masterbe
fd01:a:b:1::123            masterbe.local    masterbe
2001:db8::123              masterbe.local    masterbe

Back to #IPv6 Configuration

Prerequsites

Verify that IPv6 is active on each MythTV host.

If ssh, for example, is known to work, a simple test (run from the master backend) is:

for HOST in <list all frontend and slave backends here>
do  ssh -6 $HOST hostname
done

If the test works for all frontends and slave backends, IPv6 can be added to MythTV.

If the above fails, see the following section.

Back to #IPv6 Configuration

What if there's a problem

  • Make sure IPv6 hasn't been disabled either system wide or for the interface MythTV will use. Type:

sysctl -a | grep ipv6

net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0
net.ipv6.conf.eth0.disable_ipv6 = 0
  • Some distributions keep these options in files under /etc/sysctl.d.
  • Be sure any firewalls have been adjusted to accept the IPv6 addresses being used.
  • MySQL connections are currently selected by the hostname information in config.xml and mysql.txt files. Unless a version of MySQL that supports IPv6 is being used, no changes are required.
  • If there are entries in /etc/hosts (etc.), for both IPv4 and IPv6 addresses that have the same hostname (which is perfectly legal,) make sure the host's preferences pick IPv4 first. /etc/gai.conf may exist and control this.

Back to #IPv6 Configuration

Tools and sample output

These examples are all from a host with mythbackend running and IPv6 configured. MySQL is running and using IPv4. Obviously, these tools can be run on frontends and slave backends.

Warning.png Warning: The output of some tools and in logfiles may expose IPv6 addresses. Some addresses contain a modified MAC address or globally addressable IPv6 addresses. When posting output to a public form, consider camouflaging them.

To make sure mythbackend and mysqld are listening for connections:

sudo netstat -pant | egrep '3306|6543'

When the backend is running, but no slave backends/frontends are connected, expect:

tcp   0  0  0.0.0.0:3306            0.0.0.0:*      LISTEN      1198/mysqld     
tcp   0  0  192.168.1.123:6543      0.0.0.0:*      LISTEN      26961/mythbackend
tcp   0  0  127.0.0.1:6543          0.0.0.0:*      LISTEN      26961/mythbackend
tcp6  0  0  fd01:a:b:1::123:6543    :::*           LISTEN      26961/mythbackend
tcp6  0  0  ::1:6543                :::*           LISTEN      26961/mythbackend

With one frontend connected and playing a recording, expect:

tcp   0  0 0.0.0.0:3306           0.0.0.0:*              LISTEN      1384/mysqld     
tcp   0  0 192.168.1.123:6543     0.0.0.0:*              LISTEN      26961/mythbackend
tcp   0  0 127.0.0.1:6543         0.0.0.0:*              LISTEN      26961/mythbackend
tcp   0  0 192.168.1.123:3306     192.168.1.234:56538    ESTABLISHED 1384/mysqld     
tcp   0  0 192.168.1.123:3306     192.168.1.234:56601    ESTABLISHED 1384/mysqld     
tcp   0  0 192.168.1.123:6543     192.168.1.234:42760    ESTABLISHED 26961/mythbackend
tcp   0  0 192.168.1.123:6543     192.168.1.234:42761    ESTABLISHED 26961/mythbackend
tcp   0  0 192.168.10.204:3306    192.168.1.234:56532    ESTABLISHED 1384/mysqld     
tcp6  0  0 fd01:a:b:1::123:6543   fd01:a:b:1::456:36345  ESTABLISHED 26961/mythbackend
tcp6  0  0 fd01:a:b:1::123:6543   fd01:a:b:1::456:36346  ESTABLISHED 26961/mythbackend
tcp6  0  0 ::1:6543               :::*                   LISTEN      26961/mythbackend

If installed, nmap may help diagnose the reason that a connection fails. For example, a firewall could be blocking access.

nmap -P0 -p 3306,6543 -6 --reason someHostName

The expected response is:

PORT     STATE SERVICE REASON
3306/tcp closed mysql   conn-refused
6543/tcp open   mythtv  syn-ack

Port 3306 fails in this test, as expected, because the MySQL version used doesn't support IPv6 (remove the -6 flag above and this will work.)

Additional information is available from both mythbackend and mythfrontend if the --loglevel debug is used.

mythbackend --verbose general --nodblog --quiet \
    --logpath /var/log/mythtv --loglevel debug

A running backend's loglevel can be changed by typing:

mythbackend --setloglevel debug --quiet --nodblog

Back to #IPv6 Configuration