LoginSignup
1
2

More than 1 year has passed since last update.

YAMAHA RTX830 を使って IPv4 PPPoE と IPv6 IPoE の分離をした話

Last updated at Posted at 2022-01-12

まあまあ前に業務用ルータである YAMAHA RTX830 を使用して自宅のサーバにアクセスするための IPv4 PPPoE と普段の生活で使うための IPv6 IPoE (OCN バーチャルコネクト) を分離させたのでその覚書として.

TL;DR

  • VLAN 機能を使い, IPv6 IPoE を VLAN1 (192.168.10.0/24), IPv4 PPPoE を VLAN2 (192.168.20.0/24) に設定
  • PPPoE での接続のうち, SSH ポート (今回は 22222 番) と http(s) (80, 443) ポートをサーバの方に IP マスカレード1
  • サーバでは, IPoE での通信をデフォルトにしたいので systemd-networkd の設定で DGW を 192.168.10.1 に設定

環境

以下の環境でネットワークを構築しました (ネットワーク図は書けてないです…)

  • ルータ: YAMAHA RTX830
  • サーバ: Gentoo (5.10.76-gentoo-r1)
    • NIC (Intel I350T2-V2) を追加で挿しています.

config

最終的にできた config が以下になります.

login password *
administrator password encrypted *
login user <user_name> *
user attribute connection=serial,telnet,remote,ssh,sftp,http gui-page=dashboard
,lan-map,config login-timer=300
user attribute <user_name> connection=serial,telnet,remote,ssh,sftp,http gui-page=dash
board,lan-map,config login-timer=600
console character ja.utf8
ip route default gateway tunnel 1 gateway pp 1 filter 1
ipv6 prefix 1 ra-prefix@lan2::/64
vlan port mapping lan1.1 vlan1
vlan port mapping lan1.2 vlan1
vlan port mapping lan1.3 vlan1
vlan port mapping lan1.4 vlan2
description vlan1 "LAN(IPv6 IPoE)"
lan type lan1 port-based-option=divide-network
ip vlan1 address 192.168.10.1/24
ipv6 vlan1 address ra-prefix@lan2::1/64
ipv6 vlan1 rtadv send 1 o_flag=on
ipv6 vlan1 dhcp service server
description vlan2 "LAN(IPv4 PPPoE)"
ip vlan2 address 192.168.20.1/24
ip vlan2 dhcp service server
description lan2 ipoe
ipv6 lan2 secure filter in 101000 101001 101002 101003
ipv6 lan2 secure filter out 101099 dynamic 101080 101081 101082 101083 101084 1
01085 101098 101099
ipv6 lan2 dhcp service client ir=on
pp select 1
 description pp PPPoE
 pp keepalive interval 30 retry-interval=30 count=12
 pp always-on on
 pppoe use lan2
 pppoe auto disconnect off
 pp auth accept pap chap mschap mschap-v2
 pp auth myname <auth_id> <auth_pass>
 ppp lcp mru on 1454
 ppp ipcp ipaddress on
 ppp ipcp msext on
 ppp ccp type none
 ip pp secure filter in 400000 400001 400002 400003 400004 400020
 400021 400022 400023 400024 400025 400026 400031 400033 400199
 ip pp secure filter out 400013 400014 400020 400021 400022 400023 400024 40002
5 400026 400027 400099 dynamic 400080 400081 400082 400083 400084 400085 400098
 400099
 ip pp nat descriptor 2000
 pp enable 1
tunnel select 1
 tunnel encapsulation map-e
 tunnel map-e type ocn
 ip tunnel mtu 1460
 ip tunnel secure filter in 400000 400001 400002 400003 400004 400020 400021 40
0022 400023 400024 400025 400026 400030 400032
 ip tunnel secure filter out 400013 400014 400020 400021 400022 400023 400024 4
00025 400026 400027 400099 dynamic 400080 400081 400082 400083 400084 400085 40
0098 400099
 ip tunnel nat descriptor 20000
 tunnel enable 1
ip filter 1 pass 192.168.20.0/24 * * * *
ip filter 400000 reject 10.0.0.0/8 * * * *
ip filter 400001 reject 172.16.0.0/12 * * * *
ip filter 400002 reject 192.168.0.0/16 * * * *
ip filter 400003 reject 192.168.10.0/24 * * * *
ip filter 400004 reject 192.168.20.0/24 * * * *
ip filter 400010 reject * 10.0.0.0/8 * * *
ip filter 400011 reject * 172.16.0.0/12 * * *
ip filter 400012 reject * 192.168.0.0/16 * * *
ip filter 400013 reject * 192.168.10.0/24 * * *
ip filter 400014 reject * 192.168.20.0/24 * * *
ip filter 400015 reject 192.168.10.0/24 192.168.20.0/24 * * *
ip filter 400016 reject 192.168.20.0/24 192.168.10.0/24 * * *
ip filter 400020 reject * * udp,tcp 135 *
ip filter 400021 reject * * udp,tcp * 135
ip filter 400022 reject * * udp,tcp netbios_ns-netbios_ssn *
ip filter 400023 reject * * udp,tcp * netbios_ns-netbios_ssn
ip filter 400024 reject * * udp,tcp 445 *
ip filter 400025 reject * * udp,tcp * 445
ip filter 400026 restrict * * tcpfin * www,21,nntp
ip filter 400027 restrict * * tcprst * www,21,nntp
ip filter 400030 pass * 192.168.10.0/24 icmp * *
ip filter 400031 pass * 192.168.20.0/24 icmp * *
ip filter 400032 pass * 192.168.10.0/24 tcp * ident
ip filter 400033 pass * 192.168.20.0/24 tcp * ident
ip filter 400034 pass * 192.168.100.0/24 tcp,udp * domain
ip filter 400035 pass * 192.168.100.0/24 udp domain *
ip filter 400036 pass * 192.168.100.0/24 udp * ntp
ip filter 400037 pass * 192.168.100.0/24 udp ntp *
ip filter 400099 pass * * * * *
ip filter 400199 pass * 192.168.20.0/24 * * *
ip filter 500000 restrict * * * * *
ip filter dynamic 400080 * * ftp
ip filter dynamic 400081 * * domain
ip filter dynamic 400082 * * www
ip filter dynamic 400083 * * smtp
ip filter dynamic 400084 * * pop3
ip filter dynamic 400085 * * submission
ip filter dynamic 400098 * * tcp
ip filter dynamic 400099 * * udp
nat descriptor type 2000 masquerade
nat descriptor masquerade static 2000 1 192.168.20.100 tcp www,https,22222
nat descriptor type 20000 masquerade
nat descriptor address outer 20000 map-e
ipv6 filter 101000 pass * * icmp6 * *
ipv6 filter 101001 pass * * tcp * ident
ipv6 filter 101002 pass * * udp * 546
ipv6 filter 101003 pass * * 4
ipv6 filter 101099 pass * * * * *
ipv6 filter dynamic 101080 * * ftp
ipv6 filter dynamic 101081 * * domain
ipv6 filter dynamic 101082 * * www
ipv6 filter dynamic 101083 * * smtp
ipv6 filter dynamic 101084 * * pop3
ipv6 filter dynamic 101085 * * submission
ipv6 filter dynamic 101098 * * tcp
ipv6 filter dynamic 101099 * * udp
syslog notice on
syslog debug on
telnetd service off
telnetd host lan
dhcp service server
dhcp server rfc2131 compliant except remain-silent
dhcp scope 1 192.168.10.2-192.168.10.191/24
dhcp scope 2 192.168.20.2-192.168.20.191/24
dhcp scope bind 1 192.168.10.100 ethernet <サーバの MAC アドレス #1>
dhcp scope bind 2 192.168.20.100 ethernet <サーバの MAC アドレス #2>
dns host vlan1 vlan2
dns service fallback on
dns server dhcp lan2
dns server select 500000 dhcp lan2 any .
dns private address spoof on
sshd service on
sshd host key generate *
statistics traffic on

config の説明

長いので一部分だけ抜粋します.

login password *
administrator password encrypted *
login user <user_name> *
user attribute connection=serial,telnet,remote,ssh,sftp,http gui-page=dashboard
,lan-map,config login-timer=300
user attribute <user_name> connection=serial,telnet,remote,ssh,sftp,http gui-page=dash
board,lan-map,config login-timer=600
console character ja.utf8

ここでは, ユーザの設定とコンソールの文字コードを指定います.
基本的に直接 CLI でいじることはないと思います (文字コード指定はいじるかも).

ip route default gateway tunnel 1 gateway pp 1 filter 1
ipv6 prefix 1 ra-prefix@lan2::/64
vlan port mapping lan1.1 vlan1
vlan port mapping lan1.2 vlan1
vlan port mapping lan1.3 vlan1
vlan port mapping lan1.4 vlan2

1 行目は WAN に出ていくときの DGW 及びフィルターを設定しています.
2 行目は IPv6 における RA を LAN 側に転送する設定で, プレフィックス (詳細は RFC あたり読んだ方が早いかも)を配布しています.
3 ~ 6 行目が VLAN とポートの関係で, lan1.4 ポートのみ VLAN2 に所属するようにしています.

description vlan1 "LAN(IPv6 IPoE)"
lan type lan1 port-based-option=divide-network
ip vlan1 address 192.168.10.1/24
ipv6 vlan1 address ra-prefix@lan2::1/64
ipv6 vlan1 rtadv send 1 o_flag=on
ipv6 vlan1 dhcp service server

VLAN1 (IPv6 IPoE) の設定です. 192.168.10.0/24 のネットワークに所属するようにしています.

description vlan2 "LAN(IPv4 PPPoE)"
ip vlan2 address 192.168.20.1/24
ip vlan2 dhcp service server

VLAN2 (IPv4 PPPoE) の設定です. 192.168.20.0/24 のネットワークに所属しているようにしています.

description lan2 ipoe
ipv6 lan2 secure filter in 101000 101001 101002 101003
ipv6 lan2 secure filter out 101099 dynamic 101080 101081 101082 101083 101084 1
01085 101098 101099
ipv6 lan2 dhcp service client ir=on

IPv6 におけるフィルタリングや DHCP の設定です. WAN からもらった  IPv6 は LAN 側にもグローバルな IP を振るのでルータ側でフィルタリングさせる必要があります.

pp select 1
 description pp PPPoE
 pp keepalive interval 30 retry-interval=30 count=12
<省略>

PPPoE での接続です. 基本的には公式の設定例から抜き出してきました.
なお, ip pp nat descriptor 2000 は後述する IP マスカレードで必要な設定です.

tunnel select 1
 tunnel encapsulation map-e
 tunnel map-e type ocn
<省略>

IPoE のトンネルを張るための設定です. こちらも公式の設定例から.
ip tunnel nat descriptor 20000 も同様に IP マスカレードで必要な設定です.

ip filter 1 pass 192.168.20.0/24 * * * *
ip filter 400000 reject 10.0.0.0/8 * * * *
ip filter 400001 reject 172.16.0.0/12 * * * *
<省略>

PPPoE におけるフィルタリングの一覧です. 説明しきれないのでここはドキュメントを読んでくれればありがたいです.

nat descriptor type 2000 masquerade
nat descriptor masquerade static 2000 1 192.168.20.100 tcp www,https,22222
nat descriptor type 20000 masquerade
nat descriptor address outer 20000 map-e

IP マスカレードの設定です. サーバ (192.168.20.100) に http(s) と SSH (22222) を通しています.
IPv6 IPoE は外向きへ MAP-E での変換が必要なためこのようになってます.

ipv6 filter 101000 pass * * icmp6 * *
ipv6 filter 101001 pass * * tcp * ident
ipv6 filter 101002 pass * * udp * 546
ipv6 filter 101003 pass * * 4
ipv6 filter 101099 pass * * * * *
ipv6 filter dynamic 101080 * * ftp
ipv6 filter dynamic 101081 * * domain
ipv6 filter dynamic 101082 * * www
ipv6 filter dynamic 101083 * * smtp
ipv6 filter dynamic 101084 * * pop3
ipv6 filter dynamic 101085 * * submission
ipv6 filter dynamic 101098 * * tcp
ipv6 filter dynamic 101099 * * udp

IPoE におけるフィルタリングの一覧です. これも説明しきれないので省略.

syslog notice on
syslog debug on
telnetd service off
telnetd host lan
dhcp service server
dhcp server rfc2131 compliant except remain-silent
dhcp scope 1 192.168.10.2-192.168.10.191/24
dhcp scope 2 192.168.20.2-192.168.20.191/24
dhcp scope bind 1 192.168.10.100 ethernet <サーバの MAC アドレス #1>
dhcp scope bind 2 192.168.20.100 ethernet <サーバの MAC アドレス #2>
dns host vlan1 vlan2
dns service fallback on
dns server dhcp lan2
dns server select 500000 dhcp lan2 any .
dns private address spoof on
sshd service on
sshd host key generate *
statistics traffic on

ルータの DHCP 機能を有効にし, サーバに固定アドレスを降らせています.
また, DNS 機能も有効にしています.
加えて, telnet での通信を無効にし, SSH でのルータアクセスを有効にしています.
あとは, ログや統計機能をつけています.

systemd-networkd の設定

IPoE:

/etc/systemd/network/50-wired.network
[Match]
Name=<インタフェース名>

[Network]
Address=192.168.10.100/24
Gateway=192.168.10.1

PPPoE:

/etc/systemd/network/51-pppoe.network
[Match]
Name=<インタフェース名>

[Network]
Address=192.168.20.100/24

[Route]
Gateway=192.168.20.1
Destination=default

  1. いわゆるポートフォワーディング, YAMAHA のドキュメントでは IP マスカレードと表記するらしい 

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2