通りすがりの者です。 普段は殆どこのメールングリストは読んでいないのですが、 偶然本件を見かけまして・・
本題(「v6プラス 固定IPサービス」)では無かったようですが、 「v6プラス」の方のこちら: > (3) MAP-E方式に対応するよう、FreeBSD の NAT 周りに手を入れる 数年前に個人的に手を入れて使用している物がありますので、 もしかしたら応用できる方がいらっしゃるかもしれないと思い、 ご参考までに情報を貼らせて頂きます。 ※個人的用途なので汎用化はしておらず、 ・割当てアドレスに応じたパラメータを設定とパッチ内に埋め込む必要があり、 この辺り(例)を参考に値を求める必要があります: https://gato.intaa.net/archives/13173 http://ipv4.web.fc2.com/map-e.html ・ipfw natを使用していますが、その中の"same_ports"スイッチを MAP-E動作への切替スイッチに転用しています。 ※数年間実用していたものがベースですが、 今回投稿用に設定の抽象化とパッチの仕立て直しをしているので、 誤りがあったりしたらごめんなさい。 ** /etc/rc.conf ** ifconfig_<v6plusIF>_ipv6="inet6 accept_rtadv" ifconfig_<v6plusIF>_alias0="inet6 <CE IPv6 240b:xxxxxxxx> prefixlen 64" ifconfig_gif0="inet6 tunnel <CE IPv6 240b:xxxxxxxx> <PEERADDR 2404:xxxxxxxx> prefixlen 64 mtu 1460 up" ifconfig_gif0_alias0="inet <CE IPv4 アドレス> <CE IPv4 アドレス> netmask 255.255.255.255" ** ipfwルール ** kldload ipfw_nat kldload ipfw_pmod sysctl net.inet.ip.fw.one_pass=0 MAP_E_MYIP=<CE IPv4 アドレス> ipfw nat 100 config ip ${MAP_E_MYIP} same_ports deny_in 00100 allow ip from any to any via lo0 : skipto 20000 ip6 from any to any via <v6plusIF> : reass ip from any to any in allow icmp from any to any in icmptypes 8 allow icmp from any to any out icmptypes 0 skipto 10000 ip from any to any via gif0 : 10000 check-state :gif_nat tcp-setmss 14xx tcp from any to any tcpflags syn : 15000 nat 100 ip from any to any keep-state :gif_nat allow ip from any to any 20000 check-state :ip6_flow : allow ipencap from <CE IPv6 240b:xxxxxxxx> to <PEERADDR 2404:xxxxxxxx> out allow ipencap from <PEERADDR 2404:xxxxxxxx> to <CE IPv6 240b:xxxxxxxx> in : deny ip from any to any ** デフォルトルート設定 ** route delete 0.0.0.0 route add 0.0.0.0 -interface gif0 以下、パッチ(releng/12.2)-> Index: sys/netinet/libalias/alias_db.c =================================================================== --- sys/netinet/libalias/alias_db.c (revision 369447) +++ sys/netinet/libalias/alias_db.c (working copy) @@ -570,6 +570,14 @@ another link concurrently. This is because GetNewPort() looks for unused triplets: (dest addr, dest port, alias port). */ +#define MAPE_IPV6_PREFIX (0x240bxxxxxxxxxxxxL) ※IPv6 プレフィックス/64 +#define MAPE_PSID ((int)((MAPE_IPV6_PREFIX >> 8) & 0xff)) +static int convertToMapE( int v ){ + v = (v % 0xf0) + 0x10; + v = ((v & 0xf0) << 8) | (MAPE_PSID<<4) | (v & 0x0f); + return v; +} + static int GetNewPort(struct libalias *la, struct alias_link *lnk, int alias_port_param) { @@ -577,6 +585,7 @@ int max_trials; u_short port_sys; u_short port_net; + int mape_flag = 0; LIBALIAS_LOCK_ASSERT(la); /* @@ -603,8 +612,10 @@ * this is already in use, the remainder of the * trials will be random. */ + mape_flag = 1; port_net = lnk->src_port; port_sys = ntohs(port_net); + max_trials = 240 + GET_NEW_PORT_MAX_ATTEMPTS; } else { /* First trial and all subsequent are random. */ port_sys = arc4random() & ALIAS_PORT_MASK; @@ -628,6 +639,10 @@ int go_ahead; struct alias_link *search_result; + if ( mape_flag ){ + port_net = htons(convertToMapE(port_sys)); + } + search_result = FindLinkIn(la, lnk->dst_addr, lnk->alias_addr, lnk->dst_port, port_net, lnk->link_type, 0); @@ -637,6 +652,16 @@ else if (!(lnk->flags & LINK_PARTIALLY_SPECIFIED) && (search_result->flags & LINK_PARTIALLY_SPECIFIED)) go_ahead = 1; + else if ( mape_flag && search_result->link_type == LINK_TCP + && search_result->data.tcp->state.out != ALIAS_TCP_STATE_CONNECTED + && search_result->data.tcp->state.in != ALIAS_TCP_STATE_CONNECTED + && search_result->expire_time == TCP_EXPIRE_DEAD + && i >= GET_NEW_PORT_MAX_ATTEMPTS + ){ + DeleteLink(search_result); + search_result = NULL; + go_ahead = 1; + } else go_ahead = 0; @@ -658,9 +683,14 @@ } #endif } - port_sys = arc4random() & ALIAS_PORT_MASK; - port_sys += ALIAS_PORT_BASE; - port_net = htons(port_sys); + if ( mape_flag && i >= GET_NEW_PORT_MAX_ATTEMPTS ){ + port_sys++; + } + else{ + port_sys = arc4random() & ALIAS_PORT_MASK; + port_sys += ALIAS_PORT_BASE; + port_net = htons(port_sys); + } } #ifdef LIBALIAS_DEBUG Index: sys/netinet6/in6_gif.c =================================================================== --- sys/netinet6/in6_gif.c (revision 369447) +++ sys/netinet6/in6_gif.c (working copy) @@ -324,7 +324,7 @@ * it is too painful to ask for resend of inner packet, to achieve * path MTU discovery for encapsulated packets. */ - return (ip6_output(m, 0, NULL, IPV6_MINMTU, 0, NULL, NULL)); + return (ip6_output(m, 0, NULL, 0/*IPV6_MINMTU*/, 0, NULL, NULL)); } static int <-パッチここまで On Sat, 6 Mar 2021 05:01:44 +0900 Hiroo Ono (小野寛生) <hiroo.ono+free...@gmail.com> wrote: > 小野寛生です。 > > 結論から言うと、残念ですが FreeBSD では実用上無理です。 > > 2021年3月5日(金) 23:51 WATANABE Takeo <t...@kasaneiro.jp>: > > > > 渡部と申します。 > > > > フレッツ光クロスを契約して, > > JPNlE社の「v6プラス 固定IPサービス」に対応したISP(*1)と契約して, > > FreeBSDを用いて,v4 over v6 IPoE接続によるインターネット接続を試みています。 > > > > (*1) https://www.jpne.co.jp/service/v6plus-static/ > > > > かなりネットの海を泳いだのですが,これと言った先行事例の記事が見つからず, > > 挫折しています。ただ, > > > > https://people.allbsd.org/~hrs/FreeBSD/sato-FBSDW20170825.pdf > > > > では,「gifトンネルでは大丈夫」(p.15)との記載があり,できるものだと信じていあす。 > > その資料には同じく「MAP-E には非対応」とあるかと思いますが、V6プラスで提供されているのは > MAP-E 方式です。 > 参考: https://www.slideshare.net/yuyarin/i-pv4-ipv6coexistance > > https://bokut.in/note/2020/03/ > によれば、pf を使えば*一応*動くところまで設定可能なようですが、実用にはならないようです。 > NetBSD や OpenBSD ではどうなのかは分かりません。 > > 対応策としては、 > (1) MAP-E 方式に対応しているルーターか Linux を用いて設定する > (2) IPoE 方式を取っている ISP に乗り換える > (3) MAP-E方式に対応するよう、FreeBSD の NAT 周りに手を入れる > > のどれかかなと思います。 > > > ところが,私はトンネルを張った接続を行ったことがなく, > > 何をどのようにしたらよいのか分かりません。 > > > > 「教えて君」になってしまい申し訳ありませんが, > > どなたか教えて頂けませんでしょうか。 > > > > ●ISPからもらっている情報。 > > > > 1. IPv6プレフィックス : aaaa : bbbb :cccc : dddd : eeee : ffff : gggg : > > hhhh / 56 > > 2. IPv4アドレス : 192. 168. 100. 119 / 32 > > 3. インターフェースID : iiiii : jjjjj : kkkk : llll > > 4. Border Relay アドレス : mmmm : nnnn : oooo : pp :: 65 > > > > > > ●うちのネットワーク環境は下記のとおりです。 > > > > +------------------+ > > 192.168.131.64/27 ------| FreeBSD > > Router|-----ONU----NGN網----VNE(JPNE)----The Net > > LAN1( .65 )---------LAN2(なし) > > > > > > ●ヤマハさんの設定事例集 > > http://www.rtpro.yamaha.co.jp/RT/docs/ipip/index.html#setting11 > > > > から, > > > > LAN1のアドレスは「192.168.131.65」かつ, > > 「RAプロキシで取得したプレフィックス) : (インターフェイスID) / 64」になるようです。 > > > > # うちの回線はひかり電話未契約です。 > > > > どのようにネットワークの設定(とくに,IPIPトンネル(gif)を張ればよいか, > > どうかご教示願います。 > > > > 宜しくお願い致します。 > > > > --- > > 渡部 岳郎(WATANABE, Takeo) / JA1CPJ > > t...@kasaneiro.jp > > _______________________________________________ > > freebsd-users-jp@freebsd.org mailing list > > https://lists.freebsd.org/mailman/listinfo/freebsd-users-jp > > To unsubscribe, send any mail to "freebsd-users-jp-unsubscr...@freebsd.org" > _______________________________________________ > freebsd-users-jp@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-users-jp > To unsubscribe, send any mail to "freebsd-users-jp-unsubscr...@freebsd.org" _______________________________________________ freebsd-users-jp@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-users-jp To unsubscribe, send any mail to "freebsd-users-jp-unsubscr...@freebsd.org"