目次
VyOSの基礎的な設定。
初期のログインユーザとパスワードは以下。
ID : vyos PW : vyos
設定モードへの切り替えは以下のコマンドを使用する。設定モードに切り替わると、プロンプトが#に変化する。
configure
書き込んだ設定を有効化するには以下のコマンドを使用する。この状態では設定が反映されたのみとなるため、再起動をすると設定内容は消失する。
commit
設定内容を保存する。保存された設定は再起動後も再現される。
save
ルータの再起動/停止を行う場合には、configureモードから抜ける必要がある。
$ reboot Proceed with reboot? (Yes/No) [No] yes
$ poweroff Proceed with poweroff? (Yes/No) [No] yes
各インターフェイスにIPアドレスを設定する。
configure set interfaces ethernet [Device] address [IP Address]/[Netmask(bit)] commit save
set interfaces ethernet eth0 address 10.10.0.253/16
set interfaces ethernet eth1 address 192.168.1.253/24
システムのホスト名を設定する。
set system host-name [HostName]
DNSサーバの設定を行う。nslookupコマンドが使用できるため、commitした後に名前解決ができることを確認する。
configure set system name-server [IP Address] commit save
デフォルトゲートウェイのアドレスを設定する。
configure set system gateway-address [IP Address] commit save
NTPサーバの指定とタイムゾーンの指定を行う。
configure set system ntp server [IP Address] set system time-zone [TimeZone] commit save
configure set system ntp server ntp.nict.jp set system time-zone Asia/Tokyo commit save
デフォルトタイムゾーンはUTCになっている。
# date Wed Aug 16 06:12:33 UTC 2017
タイムゾーン設定をcommitすると、現地時間で表示される。
# set system time-zone Asia/Tokyo [edit] # commit [ system time-zone Asia/Tokyo ] Stopping enhanced syslogd: rsyslogd. Starting enhanced syslogd: rsyslogd. # date Wed Aug 16 15:13:57 JST 2017
インターフェイス間のNATを設定する。
configure set nat source rule [Rule Num] source address [Source Network] set nat source rule [Rule Num] translation address [NAT Address] set nat source rule [Rule Num] outbound-interface [Device] commit save
configure set nat source rule 1 source address 10.10.0.253/16 set nat source rule 1 translation address 192.168.1.253 set nat source rule 1 outbound-interface eth1 commit save
Firewallの基礎的な設定。
eth0からeth1へ抜ける通信は全て許可するが、eth1からeth0へ抜ける設定は全て拒否する場合の設定。
set firewall name OUTSIDE-IN default-action drop set firewall name OUTSIDE-IN rule 10 action accept set firewall name OUTSIDE-IN rule 10 state established enable set firewall name OUTSIDE-IN rule 10 state related enable] set firewall name OUTSIDE-IN rule 100 action drop set firewall name OUTSIDE-IN rule 100 state invalid enable
set interfaces ethernet eth1 firewall in name OUTSIDE-IN
外部からの特定のポートの通信を許可する場合には、以下の設定を行う。
ルールの番号は11〜99の間で重複しない番号を適宜使用する。
set firewall name OUTSIDE-IN rule 15 action accept set firewall name OUTSIDE-IN rule 15 protocol tcp set firewall name OUTSIDE-IN rule 15 destination port 80
リモートアクセス用のSSHサービスを有効化する手順。
configure set service ssh commit save
監視用にSNMPサービスを有効化する手順。
configure set service snmp community [COMMUNITY NAME] commit save
DHCPサーバ機能を有効化する手順。
configure set service dhcp-server shared-network-name [NAME] subnet [SUBNET/BIT] start [START IP] stop [END IP] set service dhcp-server shared-network-name [NAME] subnet [SUBNET/BIT] default-router [GATEWAY] set service dhcp-server shared-network-name [NAME] subnet [SUBNET/BIT] dns-server [DNS] commit save
configure set service dhcp-server shared-network-name eth1 subnet 172.16.0.0/16 start 172.16.1.10 stop 172.16.1.250 set service dhcp-server shared-network-name eth1 subnet 172.16.0.0/16 default-router 172.16.0.254 set service dhcp-server shared-network-name eth1 subnet 172.16.0.0/16 dns-server 172.16.0.200 commit save
configure set system login user [UserName] set system login user [UserName] authentication plaintext-password [Password] commit save
configure set system login user [UserName] authentication plaintext-password [Password] commit save