12
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

VyOSインストールメモ

Last updated at Posted at 2017-03-29

Deploy

公式からOVAをダウンロードしてデプロイ。起動。

メモ:

  • デプロイ時、IPアドレスはstaticにアサインできない(DHCPしかない)
  • 起動直後に/sbin/ifconfigで確認すると、IPv4のアドレスは振られていない(DHCPサーバいない環境なので当たり前ではある)

設定

ログインはvyos/vyos
今回はOVAなので、install imageは不要。コンソールでログインし、まずはIPアドレスだけ。

vyos@vyos:~$ configure
vyos@vyos# set interfaces ethernet eth0 address '10.32.46.243/24'
vyos@vyos# set interfaces ethernet eth0 description 'outside'
vyos@vyos# set service ssh port 22
vyos@vyos# set system gateway-address 10.32.46.1
vyos@vyos# commit
vyos@vyos# save

これでSSHでログインできるようになるので、あとはSSHで。

NIC追加

OVAだとデフォルトでは1つしかNICがないため追加する。単純にVMの設定編集からでOK。
メモ:

  • デフォルトのNICはVMXNET3だが、追加時はE1000しか選べなかった。追加後にreboot。

残りのネットワーク設定

eth1へのIPアドレス設定

vyos@vyos# set interfaces ethernet eth1 address '192.168.11.243/24'
vyos@vyos# set interfaces ethernet eth1 description 'inside'

タイムゾーン

vyos@vyos# set system time-zone 'Asia/Tokyo'

NTP

vyos@vyos# del system ntp server
vyos@vyos# set system ntp server '192.168.11.5'

DNS

vyos@vyos# del system name-server

  Nothing to delete (the specified node does not exist)

vyos@vyos# set system name-server '10.254.174.10'
vyos@vyos# set system name-server '192.168.11.5'
vyos@vyos# set system domain-search domain 'ngy.local'

SNATの設定(IPマスカレード)

vyos@vyos# set nat source rule 100 outbound-interface 'eth0'
vyos@vyos# set nat source rule 100 source address '192.168.11.0/24'
vyos@vyos# set nat source rule 100 translation address masquerade

ここまでで、192.168.11.0/24にあるマシンは、ゲートウェイとして192.168.11.243を指定すれば外に出ていける。
ただ、外からこのVMへはアクセスできない。
ruleの番号は小さいほうから順にチェックされ、当てはまればそれが、当てはまらなければ次へ、となる。

DNS forwardingの設定

vyos@vyos# set service dns forwarding cache-size '0'
vyos@vyos# set service dns forwarding listen-on 'eth1'
vyos@vyos# set service dns forwarding name-server '10.254.174.10'
vyos@vyos# set service dns forwarding name-server '192.168.11.5'

これで、192.168.11.0/24にあるマシンは、DNSとして192.168.11.243(VyOSのeth1)を指定すれば名前解決可能。

DNATの設定(ポートフォワーディング)

vyos@vyos# set nat destination rule 10 description 'Port Forward: SSH to 192.168.11.120'
vyos@vyos# set nat destination rule 10 destination port '2201'
vyos@vyos# set nat destination rule 10 inbound-interface 'eth0'
vyos@vyos# set nat destination rule 10 protocol 'tcp'
vyos@vyos# set nat destination rule 10 translation address '192.168.11.120'
vyos@vyos# set nat destination rule 10 translation port '22'

これで、外からVyOSのポート2201にアクセスすれば、192.168.11.0/24にあるマシン(ここでは192.168.11.120)のポート22にアクセスできる。
ruleの番号については、同様に小さいほうから。

所感

お手軽です。検証環境のIPアドレスがあんまり取れない環境なので、非常に助かります。
時間見つけて、FirewallとかVPNもやりたい。

12
21
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
12
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?