GeekFactory

int128.hatenablog.com

VyOSでIP masqueradeの最小構成

VyOSで最小限のルータを設定する時のメモです。

前提

設定

GLOBAL側とINTERNAL側のインタフェースを設定します。

set interfaces ethernet eth0 description GLOBAL
set interfaces ethernet eth0 address x.x.x.x/x

set interfaces ethernet eth0 description INTERNAL
set interfaces ethernet eth0 address 192.168.0.1/24

デフォルトゲートウエイを設定します。

set protocols static route 0.0.0.0/0 next-hop x.x.x.x

INTERNAL側からGLOBAL側へのIP Masqueradeを設定します。

set nat source rule 100 outbound-interface eth0
set nat source rule 100 source address 192.168.0.0/24
set nat source rule 100 translation address masquerade

INTERNAL側のDHCPサーバを設定します。

set service dhcp-server disabled false 
set service dhcp-server shared-network-name INTERNAL subnet 192.168.0.0/24
set service dhcp-server shared-network-name INTERNAL subnet 192.168.0.0/24 default-router 192.168.0.1
set service dhcp-server shared-network-name INTERNAL subnet 192.168.0.0/24 start 192.168.0.100 stop 192.168.0.200
set service dhcp-server shared-network-name INTERNAL subnet 192.168.0.0/24 dns-server x.x.x.x

GLOBAL側からINTERNAL側へのPort Forwardingを設定します。

set nat destination rule 1 destination address x.x.x.x
set nat destination rule 1 destination port 3389
set nat destination rule 1 inbound-interface eth0
set nat destination rule 1 protocol tcp
set nat destination rule 1 translation address 192.168.0.100

参考資料