vyos.io
Debianベースのルータ用ディストリビューション。iptablesとかの設定をするよりかなり簡単。あとはUPnPが動けばなあ。(追記2023.5.7 セキュリティホールなので動かんでいいです)
自分でいろいろ設定して試行錯誤しなければならないけど、ファームの更新が期待できない安物ルータより良いかなと思う。
Ver.1.1.8はKernelがかなり古いのでVer.1.2RCがおすすめ。ブログからイメージがダウンロードできます。
blog.vyos.net
Ver.1.2RC用設定メモ。フレッツ光系の設定です。ファイヤーウォールは最低限度なのでこれから調べないと。
configure
で設定モードに入る。
commit
変更した設定を適用。
save
設定を保存。
exit
設定モード終了。
load /opt/vyatta/etc/config.boot.default
で設定をデフォルトに戻す。
設定するパソコンにはeth0、eth1、eth2があって、eth0は無視して、eth1をインターネットにeth2をLANに接続する予定。
デフォルトのID、パスワードはvyos、vyos
ログインしてから
set system time-zone Asia/Tokyo
タイムゾーン設定。
set service ssh port 22 set interfaces ethernet eth1 description INTERNET set interfaces ethernet eth2 description LAN set interfaces ethernet eth2 address 192.168.13.99/24
sshを有効にしてeth1とeth2に説明を付ける。eth2のアドレスを割り当てる。アドレス末尾が99なのは1は古いルータで稼働中だったから。
set service dhcp-server shared-network-name LAN authoritative set service dhcp-server shared-network-name LAN subnet 192.168.13.0/24 default-router 192.168.13.99 set service dhcp-server shared-network-name LAN subnet 192.168.13.0/24 dns-server 192.168.13.99 set service dhcp-server shared-network-name LAN subnet 192.168.13.0/24 domain-name local set service dhcp-server shared-network-name LAN subnet 192.168.13.0/24 lease 86400 set service dhcp-server shared-network-name LAN subnet 192.168.13.0/24 range 0 start 192.168.13.100 set service dhcp-server shared-network-name LAN subnet 192.168.13.0/24 range 0 stop 192.168.13.199
eth2でDHCPサーバーを動かす。
set service dns forwarding listen-address 192.168.13.99 set service dns forwarding name-server x.x.x.x set service dns forwarding name-server x.x.x.x
ついでにDNSのフォーワーディングの設定もする。プロバイダから指定されているDNSを入れる。
commit save
コミット、セーブ。
LAN側に何か端末を接続してIP割り当ててもらってsshでログイン。
set system login user vyos authentication plaintext-password xxxxxxxxxxxxxxxxxxxx
とりあえずデフォルトはまずいのでパスワード変更。
set service dhcp-server shared-network-name LAN subnet 192.168.13.0/24 static-mapping static-mapping-01 ip-address 192.168.13.2 set service dhcp-server shared-network-name LAN subnet 192.168.13.0/24 static-mapping static-mapping-01 mac-address 12:34:56:78:9A:BC
LAN内のSoftetherVPNサーバーのためのIP固定設定。
set interfaces ethernet eth1 pppoe 0 set interfaces ethernet eth1 pppoe 0 user-id abc@hoge.net set interfaces ethernet eth1 pppoe 0 password xxxxxxxx set interfaces ethernet eth1 pppoe 0 name-server auto set interfaces ethernet eth1 pppoe 0 defaultroute auto set interfaces ethernet eth1 pppoe 0 mtu 1454
PPPoEの設定。プロバイダから指定されている物を設定。MTUは1454。
www.infraexpert.com
set policy route PPPOE rule 100 destination address 0.0.0.0/0 set policy route PPPOE rule 100 protocol tcp set policy route PPPOE rule 100 set tcp-mss 1414 set policy route PPPOE rule 100 tcp flags SYN set interfaces ethernet eth1 pppoe 0 policy route PPPOE set interfaces ethernet eth2 policy route PPPOE
tcp-mssの設定。これをやっておかないといけないらしい。
VyOS と PPPoE と MSS clamp の設定と - ..たれろぐ..
commit save
古いルータからONUを外して接続し直してリブートしないとPPPoEの認証を通りませんでした。
設定モードから抜けて
show interfaces show interfaces pppoe
インターフェースとPPPoEの接続確認。
PPPoEで接続後、
set nat source rule 100 outbound-interface pppoe0 set nat source rule 100 source address 192.168.13.0/24 set nat source rule 100 translation address masquerade
接続できていればpppoe0に対してSNATの設定ができるようになる。これでLANから通信できる。
set nat destination rule 10 inbound-interface pppoe0 set nat destination rule 10 destination port 500,4500 set nat destination rule 10 protocol udp set nat destination rule 10 translation address 192.168.13.2
LAN内のSoftetherVPNサーバーのためのDNAT設定。
set firewall name LOCAL default-action drop set firewall name LOCAL rule 10 action accept set firewall name LOCAL rule 10 state established enable set firewall name LOCAL rule 10 state related enable set interfaces ethernet eth1 pppoe 0 firewall local name LOCAL
ルータに対してeth1から接続できないように。ESTABLISHEDとRELATEDは通過。
set firewall name INTERNET_LAN default-action drop set firewall name INTERNET_LAN rule 10 action accept set firewall name INTERNET_LAN rule 10 state established enable set firewall name INTERNET_LAN rule 10 state related enable set firewall name INTERNET_LAN rule 20 action accept set firewall name INTERNET_LAN rule 20 protocol udp set firewall name INTERNET_LAN rule 20 destination address 192.168.13.2 set firewall name INTERNET_LAN rule 20 destination port 500,4500 set interfaces ethernet eth1 pppoe 0 firewall in name INTERNET_LAN
インターネットからLANに対してeth1から接続できないように。ESTABLISHEDとRELATEDは通過。LAN内のSoftetherVPNサーバーのためにUDPの500、4500は通す。
(2018.11.27 追記)
set firewall name LAN_INTERNET default-action accept set firewall name LAN_INTERNET rule 1 action reject set firewall name LAN_INTERNET rule 1 destination address 10.0.0.0/8 set firewall name LAN_INTERNET rule 2 action reject set firewall name LAN_INTERNET rule 2 destination address 172.16.0.0/12 set firewall name LAN_INTERNET rule 3 action reject set firewall name LAN_INTERNET rule 3 destination address 192.168.0.0/16 set interfaces ethernet eth1 pppoe 0 firewall out name LAN_INTERNET
デフォルトだとプライベートアドレスが漏れるらしいので。何かWindows共有がおかしいと思ったら。