ã«ã¼ã¿ã¼ã§éã³ãã欲ãåºã¦ãã¦ãããé©å½ãªãã·ã³ã調éãã¦éã¶ãã¨ã«ãªãã¾ããã
èªåã®å®¶ã®ã«ã¼ã¿ã¼(IO DATA WN-AX2033GR)ãå¾®å¦ã«IPoEç°å¢ã ã¨ãã«ã¹ãã¼ããåºãªããã¨ï¼ã ããã200-300Mbpsãéçï¼ãç´°ããè¨å®ãã§ããªãä¸æºãªã©ãããããããã代æ¿æ段ãç©è²ãã¦ãããã§ããã¡ããã©ãããã·ã³ãåãããã®ã§ããã§ããã¾ãã
ããããæç®ã ã¨v6ã®è¨å®ã¾ã§è©³ããã¯æ¸ãã¦ãªãã£ãããããã§ããv6ã®ã»ããã«ãã»ã«åã®ãªã¼ãã¼ãããããªãåã¹ã«ã¼ãããé«ãã¯ãã ããMAP-Eã§ã»ãã·ã§ã³ï¼ãã¼ãï¼æ¯æ¸ãããã¨ããªãã®ã§ä½¿ããªãæã¯ãªãã¯ããªãã§ãããã
ç°å¢
- å
ã³ã©ãåç·ãNTTãã¬ããå
ãã¯ã¹ãç¸å½
- DTI å
ã å®ããIPoEãééããã¨PPPoEãæ¶æ»
ãã
- IPv4 over IPv6ã¯JPNEã®MAP-E
- ããã¡ã«å
ã³ã³ã»ã³ããçãã¦ããã¿ã¤ã
- ã²ããé»è©±ãªãï¼HGWãªãï¼RAã®/64ã®ã»ããDHCPv6ã®/56ã§ã¯ãªã
é·ãéã®ãããã£ããè¦ä»¶ã¨ãã¦ã¯
- åç·ã®ã¹ããã¯ãçããããã®ã§1Gbpsãã«ã§åºããã¨
- ããããç´°ããã¨ãããããã£ã¦éã¹ããã¨
- 常æéç¨ãã¦éªéã«ãªããªããµã¤ãº
ã³ã¹ãã ãã ã¨å¸è²©ã«ã¼ã¿ã¼ã«OpenWrtãç¼ãã®ãæå®ãªã®ã ããããã ã¨1Gbpsåºãªããããããã¼ãã¦ã§ã¢ãªããã¼ãã£ã³ã°ãåæã ãOpenWrtã ã¨ãã®è¾ºãã¾ãæ±ããªãã¨ããããããªçç±ã«ããæé©åãé²ãã§ããªãããããåºæ¬å¸è²©ã«ã¼ã¿ã¼ã«ä¹ã£ã¦ãããããã¯ã¹ã«ã¼ãããè¦ä»¶çã«ã¯å
¨æ»
ã§ããããããªãããªã§ãã®è¾ºãåè£ã«ãªã£ãã
- Raspberry Pi 4 Model B 10000åããã
- NanoPi R4S 8000åããã
- Celeron J1900ãç©ãã SBC 15000åããã
ä¾¡æ ¼ã¯ãã¹ã¦ã±ã¼ã¹ããã¢ããã¿ããããããè¾¼ã¿ã®æ¦ç®ãNanoPiãæå®ã ããµãã¼ãä½å¶ãããã¥ã¡ã³ããããã¾ããªããããªã®ãé£ãRasPi 4ã¯çµæ§è¯ãããããªããã¨ããããCeleron Jã¯ããããAtomãã¼ã¹ã®ã¯ã¢ããã³ã¢ã§x64ãåä½ãäºææ§ãããã©ã¤ããããªãããã§æ©ããã¨ãã»ã¨ãã©ãªãã§ããããã¨ãç´æããã¦ããã®ãããããã
ã¨ããã¾ã§èª¿ã¹ãã¨ããã§ãå人ãLattePandaãè²·ã£ã¦ãããã¨ãæãåºãããAtom Cherry Trailã®ã¯ã¢ããã³ã¢ã§æ§è½ååã ããã¨åãããLattePanda Alphaã§Core m3ã§ãªã¼ãã¼ã¹ããã¯ãããã¨ãããããã誤ç®ãããã¹ã¿ã¼ãã
Ubuntuã«ãããOpenWrtã«ãããæ©ãã ãã¨ããããUbuntu Server 20.04ã§ã¹ã¿ã¼ããã©ã£ã¡ããããã¯ä¸¡æ¹ã¯è©¦ãã¦ããªãã®ã§è¬ãã«ã¼ã¿ã¼ç¨ãããªããã£ã¹ãã使ãã¨ãããããããã«ã¼ã¿ã¼ã£ã½ãè¨å®æ¹æ³ã¯ã§ããªã
LANãã¼ãã1ã¤ãããªãã£ãã®ã§USB 3.0-GbEå¤æããã£ããããã¯ãªãã§ããããæ¿å®ã¯ä¸»ã«RealtekãASIXããããx64 Ubuntuã§ã¯ã©ã£ã¡ãç¡è¨å®ã§åããå½ç¶1Gbpsã§ãï¼OpenWRTã®å ´åã¯ã©ã¡ããè¦æ¥µãã¦å¥éãã©ã¤ãã¤ã³ã¹ãã¼ã«ãå¿
è¦ãããï¼
æè¿ã®ã¯v6ããv4 over v6ããããã¾ããã¨ãã¼ãã¦ã§ã¢ãªããã¼ãã£ã³ã°ããããã¦ãã¦ã¾ãã¾ãé«éããããå®å
¨ã«ãªã¼ãã¼ãããã§ãªããªã£ã¦ãããã¯ä¸æã§ããææã¡ã®ããéããã¨ã¯ééããªããæ©è½ã¨å®å®æ§ã¯ãã©ãã©ã ã£ãããJPNE åºå®IPã¯å¯¾å¿ãã¦ããªãã£ãã対å¿ãã¦ãã¦ããªãããã¼ãéæ¾ã§ããªãã£ããã¨ã¨ã«ããæ©è½ä¸è¶³ãããã
ææã¡ã§æã£ã¦ãããMAP-Eé対å¿ãªã®ã¨åãªãv4 over v6ã®ã«ãã»ã«åã§ããã¼ãã¦ã§ã¢ãªããã¼ãã£ã³ã°ã«å¯¾å¿ã§ããªãã®ã§CPUã®è½åä¸è¶³ã§200-300Mbpsãããããã§ãªãã¨ãããã¨ã§é¤å¤
40000åä¹ãå¯è±ªï½ãã¨ã¯ããèªåããããã£ã¦è¦å´ãããããªãã¨ãå
¬å¼ããã¥ã¡ã³ãã¿ãªãããµãµã£ã¨ã§ããã®ã§éã§æéã¨æ§è½ãè²·ããã®ã¯ããã
æ§æ
IPv4, IPv6ã®ãã¥ã¢ã«ã¹ã¿ãã¯ã«ããããããããã ãããã¯ã¤ã¾ã両æ¹å¥ã«è¨å®ãã¤ã¤ãã¾ã«å
±éã«ãªã£ããããããããéå¢ã§ãããããã©ãã£ãããããããªã
ã«ã¼ã¿ã¼ã«DHCPv4ãµã¼ãã¼ãç«ã¦ã¦ããã¾ã
ã«ã¼ã¿ã¼ã¯RAãä¸ç¶ããã ããããããL3ã¹ã¤ããã«è¿ãï¼ãã©ã¡ãã£ã¨è¿½å ã§ä»äºããï¼
- radvdã§RAãä¸ç¶
- radvdã§è¿½å ã§è¨å®ã§ããã®ã§nameserverãæ¸ãã¦ãã(1.1.1.1ãµã¼ãã¹ã®v6ã¢ãã¬ã¹ã§ãã2606:4700:4700::1111ã¨ãï¼
- RAã®ããã®ICMPv6ãããæãã«ããã®ã«ndppdã¨ããããã¤ãããã
- DHCPv6ã¯ä¸å使ããªã
ãããã¯ã¼ã¯å¨ãã§ã¯devã¯deviceã®ç¥ç§°ã§ããæåä½ï¼ã£ã¦ãªã£ã
- enp2s0: LANå´NIC
- enx18ece795bb0b: WANå´NIC
- ip6tnl0: 使ãã¨ãã¾ãåä½ããªãåªãããdevãåæã«ã§ããããªããªã®ãããããªãããããæ
å ±ã ã¨ãã®åå使ã£ã¦ããã¤ããã使ãã¨ã¯ã¾ãã®ã§ããã¾ããã
- ipip6t0: ip4ip6ãã³ãã«ãâã§ã¯ã¾ã£ãã®ã§ååå¤ãããã¤
è¨å®
è¨å®ã¯systemd-networkdã§ãããã«ãã¼ã§ããªãã¨ãããipã¨iptablesã§ããã¾ãããããããã¹ããªã®ãã¯è¬
apt purge network-manager netplan.io ifupdown
ã©ã£ãã§è¦ããã¦ããã£ããã§ããããã¯åæã¨ãã¦ãã£ãã»ããããã§ããUbuntuãããã¯ã¼ã¯ç®¡çãããã¤ãå¤ããã¦ããã¤ããåæã«åä½ããã¨ããããããªããªãã®ã§purgeã¯åºæ¬ãsystemd-networkdä¸æ¬ã§ããã¾ããã
apt install radvd npdpp isc-dhcp-server
$ cat /etc/systemd/network/10-enp2s0.network
[Match]
Name=enp2s0
[Network]
LinkLocalAddressing=ipv6
Address=192.168.0.4/24
DHCP=no
DNS=1.1.1.1
DNS=8.8.8.8
$ cat /etc/systemd/network/10-enx18ece795bb0b.network
[Match]
Name=enx18ece795bb0b
[Link]
RequiredForOnline=yes
[Network]
DNS=2606:4700:4700::1111
IPv6AcceptRA=yes
DHCP=no
Address=240b:10:xxxxxxxxxxxxxxx/64
Tunnel=ipip6t0
$ cat /etc/systemd/network/12-ipip6t0.network
[Match]
Name=ipip6t0
[Network]
IPForward=ipv4
[Route]
Destination=0.0.0.0/0
$ cat /etc/systemd/network/ipip6t0.netdev
[NetDev]
Name=ipip6t0
Kind=ip6tnl
[Tunnel]
Mode=ipip6
Local=240b:10:xxxxxxxxxxxxxxxxx
Remote=2404:9200:225:100::64
DiscoverPathMTU=yes
EncapsulationLimit=none
$ cat /etc/radvd.conf
interface enp2s0
{
AdvSendAdvert on;
prefix 240b:10:xxxxxxxxxxx::/64
{
AdvOnLink on;
AdvAutonomous on;
};
RDNSS 2606:4700:4700::1111 2001:4860:4860::8888
{
};
};
$ cat /etc/ndppd.conf
proxy enx18ece795bb0b {
router no
rule 240b:10:xxxxxxxxxxx::/64 {
iface enp2s0
}
}
$ cat /etc/dhcp/dhcpd.conf
# default
default-lease-time 600;
max-lease-time 7200;
ddns-update-style none;
authoritative;
subnet 192.168.0.0 netmask 255.255.255.0 {
option routers 192.168.0.4;
option domain-name-servers 1.1.1.1, 8.8.8.8;
range 192.168.0.100 192.168.0.199;
}
$ cat /etc/sysctl.conf
net.ipv6.conf.all.accept_ra = 1
net.ipv6.conf.enx18ece795bb0b.accept_ra = 2
net.ipv4.conf.all.forwarding=1
net.ipv6.conf.all.forwarding=1
net.netfilter.nf_conntrack_tcp_timeout_established = 3600
è¨å®ã¯è©¦è¡é¯èª¤ããªãããã£ãã®ã§ãªããçµæ§ä¸è¦ãªè¨å®ãæ··ãã£ã¦ãããªæããããåèç¨åº¦ã«ãèããã ããããã¨MAP-Eã®ã¢ãã¬ã¹è¨ç®ã¯ã°ã°ã£ã¦ãã ããã
以ä¸ã¯ã·ã§ã«ã¹ã¯ãªãããsystemdã¨ãã§èµ·åæã«èªåè¨å®ãããããã«ããã»ãããããã¤ã§ãããã¾ã ãã£ã¦ãªã
#!/bin/sh
set -ux
# https://qiita.com/s_ponta/items/5652a7be49198288ae61
RA_RANGE='240b:10:xxxx:xxxx::/64'
BR='2404:9200:225:100::64'
CE='240b:10:xxxxxxxxxxxxxxxxxxx'
IP4='xx.xx.xx.xx'
PSID='xxx'
LANDEV='enp2s0'
WANDEV='enx18ece795bb0b'
TUNDEV='ipip6t0'
# udevadm info --export-db
echo 'on' > /sys/bus/usb/devices/1-7/power/control
# no way to config this from systemd-networkd https://github.com/systemd/systemd/issues/928
ip -6 r replace $RA_RANGE dev enp2s0 tab 1
ip -6 rule add from all tab 1 priority 1000
iptables -t filter -F
iptables -t nat -F
iptables -t mangle -F
rule=1
while [ $rule -le 15 ] ; do
mark=`expr $rule + 16`
pn=`expr $rule - 1`
portl=`expr $rule \* 4096 + $PSID \* 16`
portr=`expr $portl + 15`
iptables -t nat -A PREROUTING -m statistic --mode nth --every 15 --packet $pn -j MARK --set-mark $mark
iptables -t nat -A OUTPUT -m statistic --mode nth --every 15 --packet $pn -j MARK --set-mark $mark
iptables -t nat -A POSTROUTING -p icmp -o $TUNDEV -m mark --mark $mark -j SNAT --to $IP4:$portl-$portr
iptables -t nat -A POSTROUTING -p tcp -o $TUNDEV -m mark --mark $mark -j SNAT --to $IP4:$portl-$portr
iptables -t nat -A POSTROUTING -p udp -o $TUNDEV -m mark --mark $mark -j SNAT --to $IP4:$portl-$portr
rule=`expr $rule + 1`
done
iptables -t mangle -o $TUNDEV --insert FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
ããããªãµã¤ãã®ã³ããã«ãªã£ã¦ã
ip -6 r replace $RA_RANGE dev enp2s0 tab 1
ip -6 rule add from all tab 1 priority 1000
ããã¯ã¡ãã£ã¨å¤§äºã§ãã¦ãsystemd-networkdã ã¨ç¾ç¶ãããããµããããå
¨ä½ã®metric (ã«ã¼ãã£ã³ã°åªå
度ãä½ãã»ããåªå
ãããï¼ãæå®ããæ¹æ³ããªãã®ã§RAãªã©ã§ã¤ããããããã©ã«ãåªå
度ã«è² ããªãããä¸æ¸ããããå ´åã¯æåã§ããå¿
è¦ãããã¾ãããã®ä¾ã ã¨ãã®subnetã¯æ¨æºã ã¨WANå´NICã«ã¢ãµã¤ã³ããã¦ãã¾ãã®ãLANå´NICã«æ»ãã¦ãã¾ãããã®ãµããããWANå´LANå´ä¸¡æ¹ã§ä½¿ããã¦ããã®ããããããã¨ãããv6ã£ã½ãã¨ãããããããèªåã¨ãã§ã¬ã³ã¸åãåºãã¦åé
å¸ã§ããDHCPv6ã®ã»ããããã£ã¦ã®ã¯ãããããã¾ãããNTTï½ãã¨ãããã¨ã§æåã¯metricå¤æ´ããrouteã追å ãã¦ãããã§ããä¸ä½æ¦å¿µã¨ãã¦table/ruleã¨ããã®ãããã®ã§ãã£ã¡ã§è¨å®ããã»ãã確å®ããã¨ãããã¨ã§ããããã£ã¦ã¾ããpriorityã¯tableã®priorityã§ãããæ¨æºã®mainã¯32000ãããã
è¨å®å¾ã¯ãããªã
$ ip -6 rule
0: from all lookup local
1000: from all lookup 1
32766: from all lookup main
$ ip -6 route list tab 1
240b:10:8ac1:e800::/64 dev enp2s0 metric 1024 pref medium
$ ip -6 route list tab main
::1 dev lo proto kernel metric 256 pref medium
240b:10:xxxxxxxxx::/64 dev enx18ece795bb0b proto kernel metric 256 pref medium
240b:10:xxxxxxxxx::/64 dev enx18ece795bb0b proto ra metric 1024 expires 2591640sec pref medium
240b:10:xxxxxxxxx::/64 dev enp2s0 proto ra metric 1024 expires 86177sec pref medium
fe80::/64 dev ipip6t0 proto kernel metric 256 pref medium
fe80::/64 dev enx18ece795bb0b proto kernel metric 256 pref medium
fe80::/64 dev enp2s0 proto kernel metric 256 pref medium
default via fe80::xxxx:xxxx:xxxx:xxxx dev enx18ece795bb0b proto ra metric 1024 expires 1440sec pref medium
ä½è«ã§ããipãiptablesãv6ã¨v4ã§å¥ã
ã«è¡¨ç¤ºããããv6ã¯ãªãã·ã§ã³ã¤ããªãã¨è¡¨ç¤ºãããªããã注æã ï¼
é度
é©å½ã«ã¯ãã£ãã¨ããv4ã§600Mbpsãããã¯åºã¦ããããã¾ã¾ã§ã¯200-300Mbpsãé度ã ã£ãã®ã§ã«ã¼ã¿ã¼ã®æ§è½ã«ãããªã¼ãã¼ãããã¯ã»ã¼æ¶ããã¨ãã£ã¦ããããããªãã ããã
課é¡
- âã§æåã§è¨å®ããmetricããªã«ãã®ã¯ãã¿ã«æ¶ãã¦ãã¾ããã¨ããããè¬ããªããªãã¨v6ã¯çéããªããªããv4ã¯éããã®ã§æ°ã¥ãã«ããã£ãã
- ã»ãã¥ãªãã£ã¼ãã¶ã«ã¨ãããç¡è¨å®ãªãã§ããã©ããªãã ãããv6ã¢ãã¬ã¹ã®è¨å®æ¹æ³ãã©ããªã£ã¦ããã調æ»ãããã¨ãããã±ãã解æãã¦ãªããå¼¾ãã¨ããã£ãã»ããããã®ãããã§ãv6ã§ã¯å
¨é¨ã°ãã¼ãã«ã¢ãã¬ã¹ãã£ã¦ã¦incomingåãä»ããããã¨ããã®ã¯ã¾ã£ã¨ããªãã¨ã§ã¯
- UPnPã¨ããMAP-Eã§ã©ãã¾ã§å¯¾å¿ãã価å¤ãããã¯ããã¨ãã¦ããããã¨ãã«ãå¯è½ãªportã§ããã°ã§ããã»ãããã
次
- enã²ããã£ã¦ããå
ã³ã©ãã®ãµã¼ãã¹ããããã§ãããMAP-Eã¨åºå®IPãªãã·ã§ã³ãã¤ããã¨æ3300+180+700=4180åã§ãã«ã®v4ã¢ãã¬ã¹ãæã¤ãã¨ãã§ãã¾ããããã§80ãã443ããã§ãµã¼ãã¼å
¬éã§ãããï¼ï¼ã¨ãããã¨ã§ãããããããã¨æãã¾ããMAP-E + åºå®IPãªãã·ã§ã³ã¯å®éã«ã¯JPNEã®åºå®IPãµã¼ãã¹ã«ãªãã®ã§ãã¡ããã¡ãããå¿
è¦ãããMAP-Eã¨ããããã°ã§ãDS-Liteãããã®è¨å®ã§ããã¾ããã»ãã·ã§ã³ãå¢ããæã®ãã¼ãæ¯æ¸ã«ãæ©ã¾ãããªããªãã¾ããããããï¼
- ãã¡ããã¡ãé«æ§è½ãªãã¤ã§ãã£ã¦ãã¾ã£ãã®ã§ã©ãã¾ã§ä½æ§è½ãä½ä¾¡æ ¼ãªã«ã¼ã¿ã¼ã§åãã¹ã«ã¼ãããåºãããã¯ãã£ã¬ã³ã¸ãã¦ã¿ããããã¨ä¸åã®ãããã¯æè¿OpenWrtã§ãã¼ãã¦ã§ã¢ãªããã¼ãã£ã³ã°å¯¾å¿ãããããã®ã§ãå¸è²©ã«ã¼ã¿ã¼ã®ã½ããã¦ã§ã¢ã§ãã£ã¦ããv4ç¨ã®ãã¼ãã¦ã§ã¢ãªããã¼ãã£ã³ã°ãv6ã§ç¡çãã使ããããã«ããããã¯ã¨ããèªåã§ããã®ã¯ããããããï¼å¤§å¤ããï¼
åèæç®
https://qiita.com/kakinaguru_zo/items/2764dd8e83e54a6605f2
https://qiita.com/s_ponta/items/5652a7be49198288ae61
https://quintrokk.subness.net/?p=2003
https://gato.intaa.net/archives/25972