我最近切換運營商,新的運營商提供給我的是一個 /48 的地址前綴,這和我之前的營運商們不一樣,他們大多使用 DHCP,直接給你分配一個 IPv6的 的地址。儘管 v6 存在的意義就是地址“無限”,但分配一個的話能省掉很多配置上的麻煩事。
這次全新的設定讓我措手不及。
好消息是,官方有教程。壞消息是,官方的教學不沃克。
這就有些讓人頭痛了,設定完沒網,即使我手動為路由器新增了靜態路由到出口,也無法路由出去。我這邊使用的是 米克羅蒂克 路由器,系統是路由器作業系統 v7
按照官方的教程,首先就是加入 dhcp 客戶端,這一步很簡單,與平時不同的是,不能勾選 address,如果勾選,則dhcp永遠處在搜尋狀態,因為沒人會回覆給你一個 ip 位址。只請求地址前綴,匹配成功。
然後是手動給你的網橋和 wan 口一個 ip 位址,你只要寫 ::/64 即可,路由器會自動產生對應的位址,儘管各個運營商給的前綴長度不同,但通常我們家用只要 /64 即可。給地址要勾選「宣告地址」這項,這樣你的電腦和手機什麼的就能搜尋到路由器並且加入網關了。
最後是到 IPv6 的設定裡開啟 IPv6,接受轉送與接受路由宣告。
最後重啟路由器,完成!
那麼問題來了…重啟之後我還是沒有 IPv6 的網。
既然 ping6 回傳的錯誤是沒有路由,那我就給它加一個,我首先就新增了全域靜態路由到 以太1,也就是我的 wan 口。這下是有路由了,不過回傳卻是 timeout,顯然,沒有人可以應答。當然,有時候也會回目標不可達。
仔細對比了 v6 版本的配置之後,我發現我缺少了防火牆配置,從網路上找了預設防火牆設定導入,但還是不行。
經過幾天在網路上找答案,終於得以解惑:
原來是需要在 ND,也就是 IPv6 的鄰居發現這裡,新增 ether1,預設只有網橋,所以就只能發現內網的所有設備。新增 eth1 到設備發現後,重啟路由器,果然在鄰居列表裡很快就發現了很多上級路由位址,路由器也成功加入了動態網關,測試發現,有網了。
接下來把我的設定用 cli 版本總結如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
ipv6 dhcp-client add interface=ether1 request=prefix pool-name=v6 pool-prefix-length=64 prefix-hint=::/48 ipv6 address add address=::/64 from-pool=v6 interface=bridge eui-64=yes advertise=yes ipv6 address add address=::/64 from-pool=v6 interface=ether1 eui-64=yes advertise=yes ipv6 firewall { address-list add list=bad_ipv6 address=::/128 comment="defconf: unspecified address" address-list add list=bad_ipv6 address=::1 comment="defconf: lo" address-list add list=bad_ipv6 address=fec0::/10 comment="defconf: site-local" address-list add list=bad_ipv6 address=::ffff:0:0/96 comment="defconf: ipv4-mapped" address-list add list=bad_ipv6 address=::/96 comment="defconf: ipv4 compat" address-list add list=bad_ipv6 address=100::/64 comment="defconf: discard only " address-list add list=bad_ipv6 address=2001:db8::/32 comment="defconf: documentation" address-list add list=bad_ipv6 address=2001:10::/28 comment="defconf: ORCHID" address-list add list=bad_ipv6 address=3ffe::/16 comment="defconf: 6bone" address-list add list=bad_ipv6 address=::224.0.0.0/100 comment="defconf: other" address-list add list=bad_ipv6 address=::127.0.0.0/104 comment="defconf: other" address-list add list=bad_ipv6 address=::/104 comment="defconf: other" address-list add list=bad_ipv6 address=::255.0.0.0/104 comment="defconf: other" filter add chain=input action=accept connection-state=established,related,untracked comment="defconf: accept established,related,untracked" filter add chain=input action=drop connection-state=invalid comment="defconf: drop invalid" filter add chain=input action=accept protocol=icmpv6 comment="defconf: accept ICMPv6" filter add chain=input action=accept protocol=udp port=33434-33534 comment="defconf: accept UDP traceroute" filter add chain=input action=accept protocol=udp dst-port=546 src-address=fe80::/10 comment="defconf: accept DHCPv6-Client prefix delegation." filter add chain=input action=accept protocol=udp dst-port=500,4500 comment="defconf: accept IKE" filter add chain=input action=accept protocol=ipsec-ah comment="defconf: accept ipsec AH" filter add chain=input action=accept protocol=ipsec-esp comment="defconf: accept ipsec ESP" filter add chain=input action=accept ipsec-policy=in,ipsec comment="defconf: accept all that matches ipsec policy" filter add chain=input action=drop in-interface-list=!LAN comment="defconf: drop everything else not coming from LAN" filter add chain=forward action=accept connection-state=established,related,untracked comment="defconf: accept established,related,untracked" filter add chain=forward action=drop connection-state=invalid comment="defconf: drop invalid" filter add chain=forward action=drop src-address-list=bad_ipv6 comment="defconf: drop packets with bad src ipv6" filter add chain=forward action=drop dst-address-list=bad_ipv6 comment="defconf: drop packets with bad dst ipv6" filter add chain=forward action=drop protocol=icmpv6 hop-limit=equal:1 comment="defconf: rfc4890 drop hop-limit=1" filter add chain=forward action=accept protocol=icmpv6 comment="defconf: accept ICMPv6" filter add chain=forward action=accept protocol=139 comment="defconf: accept HIP" filter add chain=forward action=accept protocol=udp dst-port=500,4500 comment="defconf: accept IKE" filter add chain=forward action=accept protocol=ipsec-ah comment="defconf: accept ipsec AH" filter add chain=forward action=accept protocol=ipsec-esp comment="defconf: accept ipsec ESP" filter add chain=forward action=accept ipsec-policy=in,ipsec comment="defconf: accept all that matches ipsec policy" filter add chain=forward action=drop in-interface-list=!LAN comment="defconf: drop everything else not coming from LAN" } ipv6 nd add interface=ether1 ra-interval=20s-60s ra-lifetime=none ipv6 nd set [ find interface=bridge ] dns=2606:4700:4700::1111,2001:4860:4860::8888 interface=bridge managed-address-configuration=yes ra-interval=20s-1m other-configuration=yes |
本文由 落格博客 原創撰寫:落格博客 » 如果你的運營商沒有給分配的 IPv6 只有前綴而沒有位址
轉載請保留出處和原文鏈接:https://www.logcg.com/archives/3864.html
博主你好我有个疑问,因为我是在旁路网关开启的RA,这样所有其他设备的默认网关是旁路,这种情况下还需要开启NDP吗
根據我的經驗…還是需要的,因為你的旁路也得能找到真實路由才可以。不過,如果做了靜態路由,應該就不需要nd了吧,只在旁路由開即可。