doc:appunti:net:ipv6_on_ppp
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| doc:appunti:net:ipv6_on_ppp [2024/07/05 15:31] – [Troubleshooting IPv6 problems] niccolo | doc:appunti:net:ipv6_on_ppp [2026/10/06 10:34] (current) – [Configuring Shorewall6] niccolo | ||
|---|---|---|---|
| Line 57: | Line 57: | ||
| </ | </ | ||
| - | This is the reason why the IPv6 global (public) address is propbably | + | This is the reason why the IPv6 global (public) address is probably |
| < | < | ||
| Line 73: | Line 73: | ||
| We need to hook a script to the **ppp0 up event** and configure the options there. Because we are using the Shorewall firewall it is possibile to set the required actions into the Shorewall configuration and simply restart the Shorewall service on the ppp0 interface up event. See below an example of a **/ | We need to hook a script to the **ppp0 up event** and configure the options there. Because we are using the Shorewall firewall it is possibile to set the required actions into the Shorewall configuration and simply restart the Shorewall service on the ppp0 interface up event. See below an example of a **/ | ||
| + | ==== Static vs dynamic address ==== | ||
| + | |||
| + | A very common scenario is that the Internet provider **assigns a /64 prefix to the PPP interface** and delegates an **additional prefix** to be used **for the local LAN**, generally a /56. The prefix assigned to the PPP interface is often not guaranteed to remain the same over time and should therefore be considered **dynamic**. If you have negotiated **static IPv6 addresses** with the provider, they are very likely part of this additional delegated prefix. | ||
| Line 106: | Line 109: | ||
| / | / | ||
| </ | </ | ||
| + | |||
| + | ===== Manual configuration of the IPv6 prefix delegation ===== | ||
| + | |||
| + | If your ISP assigns to you a **Prefix Delegation** (an IPv6 subnet), but it does not offer the **DHCPv6 service**, you need to configure the address manually. In our case the WAN IPv6 address is automatically negotiated on the ppp0 interface, so we manually configure the LAN IPv6 address (the delegated prefix) on the internal interface **br0**. | ||
| + | |||
| + | Just add the following section into **/ | ||
| + | |||
| + | < | ||
| + | iface br0 inet6 static | ||
| + | address 2a02: | ||
| + | netmask 64 | ||
| + | </ | ||
| + | |||
| ===== DHCPv6 client: the wide-dhcpv6-client.service ===== | ===== DHCPv6 client: the wide-dhcpv6-client.service ===== | ||
| Line 487: | Line 503: | ||
| </ | </ | ||
| - | Like for the IPv4, the **CLAMPMSS=Yes** is often required in **/etc/shorewall/shorewall.conf** (see above): | + | If you want to forward packets from internal interface to the external one (and vice-versa), |
| + | |||
| + | < | ||
| + | IP_FORWARDING=On | ||
| + | </ | ||
| + | |||
| + | Like for the IPv4, the **CLAMPMSS=Yes** is often required in **/etc/shorewall6/shorewall6.conf** (see above): | ||
| < | < | ||
| Line 548: | Line 570: | ||
| FIXME: What to do to protect LAN hosts from the internet? | FIXME: What to do to protect LAN hosts from the internet? | ||
| + | |||
| + | ===== Using a static IPv6 address ===== | ||
| + | |||
| + | You may need a **static IPv6 address** on your firewall for both incoming and outgoing connections: | ||
| + | |||
| + | * **Incoming connections: | ||
| + | * **Outgoing connections: | ||
| + | |||
| + | As stated above, the address autoamtically assigned to the **ppp0** interface may be **dynamic**, | ||
| + | |||
| + | In the configuration file **/ | ||
| + | |||
| + | That IPv6 address is guaranteed to be static and assigned to the firewall, so you can use it for incoming connections and you can register it as an AAAA record in the DNS. But outgoiung IPv6 connections originating from the firewall itself use the ppp0 address, which may be dynamic. | ||
| + | |||
| + | Therefore, we need a script that **sets the source IPv6 address** to the static address assigned to the **br0** interface, rather than the one dynamically assigned to the **ppp0** interface. This setting must be applied every time the ppp0 interface is activated, but only after the subnet delegation negotiation has completed. | ||
| + | |||
| + | Here is the sample script | ||
| + | |||
| + | <code bash> | ||
| + | #!/bin/sh | ||
| + | # / | ||
| + | |||
| + | # Execute first the default Debian script (DNS, etc.), if it exists. | ||
| + | # We do not need this because the DNS is configured locally, not via DHCPv6. | ||
| + | #[ -x / | ||
| + | |||
| + | get_src() { | ||
| + | # Global address of br0, excluding those in DAD or deprecated. | ||
| + | ip -6 addr show dev br0 scope global -tentative -deprecated \ | ||
| + | | awk '/ | ||
| + | } | ||
| + | |||
| + | # It waits up to ~5 s for DAD to complete (a " | ||
| + | # not accepted as the source address, and the command would fail). | ||
| + | i=0 | ||
| + | SRC=$(get_src) | ||
| + | while [ -z " | ||
| + | sleep 0.5 | ||
| + | i=$((i+1)) | ||
| + | SRC=$(get_src) | ||
| + | done | ||
| + | |||
| + | [ -n " | ||
| + | |||
| + | # Replaces (or adds, if it does not already exist) the default route with a metric of 100. | ||
| + | ip -6 route replace default dev ppp0 metric 100 src " | ||
| + | && logger -t dhcp6c-src " | ||
| + | exit 0 | ||
| + | </ | ||
| + | |||
| + | To hook this script to the moment the IPv6 configuration is received, modify the **/ | ||
| + | |||
| + | < | ||
| + | interface ppp0 { | ||
| + | # Send an option for " | ||
| + | send ia-pd 0; | ||
| + | # Script executed when the daemon receives a reply message. | ||
| + | script "/ | ||
| + | }; | ||
| + | </ | ||
| + | |||
| + | If you need to call the default Debian hook script **/ | ||
| + | |||
| + | You can see all the times that the script is executed (because the DHCPv6 lease renews) using the command: | ||
| + | |||
| + | < | ||
| + | journalctl --boot -t dhcp6c-src | ||
| + | </ | ||
| + | |||
| + | ===== Useful commands ===== | ||
| + | |||
| + | Mostra la **rotta predefinita** per IPv6: | ||
| + | |||
| + | < | ||
| + | ip -6 route show default | ||
| + | </ | ||
| + | < | ||
| + | default dev ppp0 metric 1024 pref medium | ||
| + | default via fe80:: | ||
| + | </ | ||
| + | |||
| + | La prima riga indica una rotta predefinita verso l' | ||
| + | |||
| + | La seconda riga viene istanziata durante la negoziazione del Router Advertisement (abbiamo '' | ||
| + | |||
| + | Visualizza l' | ||
| + | |||
| + | < | ||
| + | ip -6 addr show dev br0 scope global | ||
| + | </ | ||
| + | < | ||
| + | 5: br0: < | ||
| + | inet6 2a02: | ||
| + | | ||
| + | </ | ||
| + | |||
| + | **Imposta o rimuove manualmente** un indirizzo IPv6 su una interfaccia: | ||
| + | |||
| + | < | ||
| + | ip -6 addr add 2a02: | ||
| + | ip -6 addr del 2a02: | ||
| + | </ | ||
| + | |||
| + | Mostra la **rotta selezionata** e **indirizzo sorgente** per un indirizzo IPv6 remoto: | ||
| + | |||
| + | < | ||
| + | ip -6 route get 2a01: | ||
| + | </ | ||
| + | < | ||
| + | 2a01: | ||
| + | </ | ||
| + | |||
| + | **Imposta la rotta predefinita** IPv6 indicando l' | ||
| + | |||
| + | < | ||
| + | ip -6 route add default dev ppp0 metric 100 src 2a02: | ||
| + | </ | ||
| + | < | ||
| + | 2a01: | ||
| + | </ | ||
| ===== MRU and MTU for PPPoE ===== | ===== MRU and MTU for PPPoE ===== | ||
| Line 582: | Line 724: | ||
| < | < | ||
| - | ping -6 2a01: | + | # ping -6 2a01: |
| </ | </ | ||
| Line 588: | Line 730: | ||
| < | < | ||
| - | ip -6 address show dev enp0s7 | + | # ip -6 address show dev enp0s7 |
| </ | </ | ||
| Line 603: | Line 745: | ||
| In the example above the interface have two **global** scope addresses, one assigned via DHCPv6 and the other obtained via SLAAC. The first one has the **dadfailed** flag, which means that the **duplicate address detection** has detected a conflict in the network. This means that the IP address in question will not be used as the source address and it does not even respond to a self-ping. | In the example above the interface have two **global** scope addresses, one assigned via DHCPv6 and the other obtained via SLAAC. The first one has the **dadfailed** flag, which means that the **duplicate address detection** has detected a conflict in the network. This means that the IP address in question will not be used as the source address and it does not even respond to a self-ping. | ||
| - | If you have only one global IP address which is **dadfailed**, | + | If you have only one global IP address which is **dadfailed**, |
| - | + | ||
| - | < | + | |
| - | ip -6 route show | + | |
| - | </ | + | |
| < | < | ||
| + | # ip -6 route show | ||
| 2a02: | 2a02: | ||
| 2a02: | 2a02: | ||
| Line 616: | Line 755: | ||
| </ | </ | ||
| - | **NOTICE**: The default router can be reached via its **link** scope address (as above) or via its **global** scope address, both can be used. | + | **NOTICE**: The default router can be reached via its **link** scope address (as seen above) or via its **global** scope address: both can be used. |
| - | If you sniff the ping request on the router, you can see the problem: | + | If you sniff the ping request on the router, you can see the problem |
| < | < | ||
| + | # tcpdump -i eth0 -n ' | ||
| + | ... | ||
| IP6 fe80:: | IP6 fe80:: | ||
| id 56698, seq 1, length 64 | id 56698, seq 1, length 64 | ||
| Line 627: | Line 768: | ||
| </ | </ | ||
| - | the client uses its link scope address as source address, which causes the **beyond scope** error. You can confirm this problem on the client using the '' | + | The client uses its link scope address as source address, which causes the **beyond scope** error. You can confirm this problem on the client using the '' |
| < | < | ||
| - | ip -6 route get 2a01: | + | # ip -6 route get 2a01: |
| 2a01: | 2a01: | ||
| via 2a02: | via 2a02: | ||
| Line 642: | Line 783: | ||
| < | < | ||
| - | ip -6 route get 2a01: | + | # ip -6 route get 2a01: |
| 2a01: | 2a01: | ||
| via fe80:: | via fe80:: | ||
| Line 650: | Line 791: | ||
| </ | </ | ||
| - | In the first case the **src** address is the **link scope** one, not suitable for routing. In the second case it is the one received via SLAAC, which has a **global scope** and indeed it is working. Notice that the address of the router (shown as the **via** address) is not releveant, the //link scope// one does work. | + | In the first case the **src** address is the **link scope** one, not suitable for routing. In the second case it is the one received via SLAAC, which has a **global scope** and indeed it is working. Notice that the address of the router (shown as the **via** address) is not releveant, |
doc/appunti/net/ipv6_on_ppp.1720186285.txt.gz · Last modified: by niccolo
