4
3

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 3 years have passed since last update.

ESXi内のVyOSによるNAT設定

Last updated at Posted at 2020-03-15

##やりたいこと
・ESXi6.5内で仮想ネットワークを作ってvmware playerのネットワーク接続のNAT相当の機能を使う

##用意するもの
・ESXi6.5サーバー
・VyOS

##事前準備
###ESXi6.5
外部接続なしの仮想ネットワークを作成しておく
####ネットワーク
#####仮想スイッチ
vSwitch名:Local
MTU:1500
リンクの検出:(変更なし)
セキュリティ:(変更なし)
#####ポートグループ
名前:LoaclNetwork
VLANID:0(変更なし)
仮想スイッチ:Local
セキュリティ:(変更なし)
####仮想マシン作成(VyOSインストール用)
CPU:2vCPUs
メモリ:2GB
HDD:4GB
ネットワークアダプタ1:VM Network (eth0)
ネットワークアダプタ2:Local (eth1)

####VyOSインストール後の設定
#####やりたいこと
eth0 プライベートネットワーク
・192.168.1.0/24
・192.168.1.30(自分)

eth1 ローカル(ESXi内のみ)
・192.168.130.0/24
・192.168.130.254(自分)
・DHCPサーバ
・DNSサーバ
・NTPサーバ
・NAPT

#####初期設定
名前:VyOS1
ポート設定:
eth0:192.168.1.30/24
GW:192.168.1.1
DNS:192.168.1.1
eth1:192.168.130.254/24

set system time-zone Asia/Tokyo
set system ntp server ntp.nict.jp
set interfaces ethernet eth0 address 192.168.1.30/24
set interfaces ethernet eth0 desciption 'private'
set interfaces ethernet eth1 address 192.168.130.254/24
set interfaces ethernet eth1 descrption 'local'
set system name-server 192.168.1.1
set protocols static route 0.0.0.0/0 next-hop 192.168.1.1```

#####DHCPサーバ設定
ネットワークアドレス:192.168.130.0/24
デフォルトゲートウェイ:192.168.130.254(自分)
DNSサーバ:192.168.130.254(自分)
DHCP範囲:2~128

```set service dhcp-server shared-network-name dhcp_scope01
set service dhcp-server shared-network-name dhcp_scope01 subnet 192.168.130.0/24 default-router 192.168.130.254
set service dhcp-server shared-network-name dhcp_scope01 subnet 192.168.130.0/24 dns-server 192.168.130.254
set service dhcp-server shared-network-name dhcp_scope01 subnet 192.168.130.0/24 range 0 start 192.168.130.2
set service dhcp-server shared-network-name dhcp_scope01 subnet 192.168.130.0/24 range 0 stop 192.168.130.128```

#####DNSサーバ設定(転送)
転送先:192.168.1.1

```set service dns forwarding name-server 192.168.1.1
set service dns forwarding listen-address 192.168.130.254
set service dns forwarding allow-from 192.168.130.0/24```

#####NAPT設定
対象:192.168.130.0/24

```set nat source rule 1 outbound-interface eth0
set nat source rule 1 source address 192.168.130.0/24
set nat source rule 1 translation address masquerade```

#####NTPサーバ
対象:192.168.130.0/24

```set system ntp allow-clients address 192.168.130.0/24```

#####Firewall
######対象:eth0→eth1
デフォルト:ブロック
established:確立済みパケットは通過
related:確立済み関連パケットは通過
invalid :上記に当てはまらないパケットは破棄

```set firewall name input default-action drop
set firewall name input rule 10 action accept
set firewall name input rule 10 state established enable
set firewall name input rule 10 state related enable
set firewall name input rule 20 action drop
set firewall name input rule 20 state invalid enable
set interfaces ethernet eth0 firewall in name input```

######対象:eth1→eth0
デフォルト:通過
外部へのローカルアドレスのパケットは破棄

```set firewall name output default-action accept
set firewall name output rule 10 action reject
set firewall name output rule 10 destination address 10.0.0.0/8
set firewall name output rule 11 action reject
set firewall name output rule 11 destination address 172.16.0.0/12
set firewall name output rule 12 action reject
set firewall name output rule 12 destination address 192.168.0.0/16
set interfaces ethrnet eth0 firewall out name output```

######保存
問題がなければ
```commit
save```
4
3
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
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?