wan.rst 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. WAN support
  2. ===========
  3. As the WAN port of a node will be connected to a user's private network, it
  4. is essential that the node only uses the WAN when it is absolutely necessary.
  5. There are two cases in which the WAN port is used:
  6. * Mesh VPN (package ``gluon-mesh-vpn-fastd``
  7. * DNS to resolve the VPN servers' addresses (package ``gluon-wan-dnsmasq``)
  8. After the VPN connection has been established, the node should be able to reach
  9. the mesh's DNS servers and use these for all other name resolution.
  10. Routing tables
  11. ~~~~~~~~~~~~~~
  12. As a node may get IPv6 default routes both over the WAN and the mesh, Gluon
  13. uses two routing tables for IPv6. As all normal traffic should go over the mesh,
  14. the mesh routes are added to the default table (table 0). All routes on the WAN interface
  15. are put into table 1 (see ``/lib/gluon/upgrade/110-network`` in ``gluon-core``).
  16. There is also an *ip -6 rule* which routes all IPv6 traffic with a packet mark with the
  17. bit 1 set though table 1.
  18. libpacketmark
  19. ~~~~~~~~~~~~~
  20. *libpacketmark* is a library which can be loaded with ``LD_PRELOAD`` and will set the packet mark of all
  21. sockets created by a process in accordance with the ``LIBPACKETMARK_MARK`` environment variable. This allows setting
  22. the packet mark for processes which don't support this themselves. The process must run as root (or at least
  23. with ``CAP_NET_ADMIN``) for this to work.
  24. Unfortunately there's no nice way to set the packet mark via iptables for outgoing packets. The iptables will
  25. run after the packet has been created, to even when the packet mark is changed and the packet is re-routed, the
  26. source address won't be rewritten to the default source address of the newly chosen route. *libpacketmark* avoids
  27. this issue as the packet mark will already be set when the packet is created.
  28. gluon-wan-dnsmasq
  29. ~~~~~~~~~~~~~~~~~
  30. To separate the DNS servers in the mesh from the ones on the WAN, the ``gluon-wan-dnsmasq`` package provides
  31. a secondary DNS daemon which runs on ``127.0.0.1:54``. It will automatically use all DNS servers explicitly
  32. configured in ``/etc/config/gluon-wan-dnsmasq`` or received via DNS/RA on the WAN port. It is important that
  33. no DNS servers for the WAN interface are configured in ``/etc/config/network`` and that ``peerdns`` is set to 0
  34. so the WAN DNS servers aren't leaked to the primary DNS daemon.
  35. *libpacketmark* is used to make the secondary DNS daemon send its requests over the WAN interface.
  36. The package ``gluon-mesh-vpn-fastd`` provides an iptables rule which will redirect all DNS requests from processes running
  37. with the primary group ``gluon-fastd`` to ``127.0.0.1:54``, thus making fastd use the secondary DNS daemon.