# # 設定hostname # set system host-name <hostname> # # 設定系統時區 # set system time-zone Asia/Taipei # # 建立新的使用者 # set system login user <user> authentication plaintext-password <password> # # 刪除預設vyos的帳號 # delete system login user vyos # # 設定新帳戶的ssh金鑰 # set system login user <user> authentication public-keys <user@host> type <ssh-rsa/ssh-ed25519> # set system login user <user> authentication public-keys <user@host> key <text>
IP Address
wan
1 2 3 4 5 6
# # 設定外部網路連線 # set interface ethernet <wan port> address <dhcp/static ip> # set interface ethernet <wan port> description WAN # # 如果外網連線是static IP,則需設定IP # set interface ethernet <wan port> address <x.x.x.x/x> # set protocols static route 0.0.0.0/0 next-hop <gateway ip>
# # 進入防火牆設定層級 # edit firewall # # 以組別來管理防火牆規則 # set group interface-group WAN interface eth1 # set group interface-group LAN interface eth0 # set group network-group LAN-v4 network 10.x.x.x/24 # # 設定全域規則 # set global-options state-policy established action accept # set global-options state-policy related action accept # set global-options state-policy invalid action drop # # 設定從外部往內部轉發時的規則 # # 設定一條新的鏈,預設行為丟棄封包 # set ipv4 name OUTSIDE-IN default-action drop # # 當符合從外部網路向內部IP路由時,跳到OUTSIDE-IN的鏈上 # set ipv4 forward filter rule 100 action jump # set ipv4 forward filter rule 100 jump-target OUTSIDE-IN # set ipv4 forward filter rule 100 inbound-interface group WAN # set ipv4 forward filter rule 100 destination group network-group LAN-v4 # # 設定路由器本身的INPUT filter # # 當使用tcp訪問端口22時跳到VyOS_MANAGEMENT鏈上 # set ipv4 input filter default-action drop # set ipv4 input filter rule 20 action jump # set ipv4 input filter rule 20 jump-target VyOS_MANAGEMENT # set ipv4 input filter rule 20 destination port 22 # set ipv4 input filter rule 20 protocol tcp # # 設定一條新的鏈 # # 從內部網路來的連線全部允許 # set ipv4 name VyOS_MANAGEMENT rule 10 action accept # set ipv4 name VyOS_MANAGEMENT rule 10 inbound-interface group LAN # # 從wan來的連線,當1分鐘連線3次以上則丟棄封包 # set ipv4 name VyOS_MANAGEMENT rule 20 action drop # set ipv4 name VyOS_MANAGEMENT rule 20 recent count 3 # set ipv4 name VyOS_MANAGEMENT rule 20 recent time minute # set ipv4 name VyOS_MANAGEMENT rule 20 state new # set ipv4 name VyOS_MANAGEMENT rule 20 inbound-interface group WAN # # 允許從wan來的連線 # set ipv4 name VyOS_MANAGEMENT rule 21 action accept # set ipv4 name VyOS_MANAGEMENT rule 21 state new # set ipv4 name VyOS_MANAGEMENT rule 21 inbound-interface group WAN # # 允許回應ping # set ipv4 input filter rule 30 action accept # set ipv4 input filter rule 30 icmp type-name echo-request # set ipv4 input filter rule 30 protocol icmp # set ipv4 input filter rule 30 state new # # 允許本機的所有連線 # set ipv4 input filter rule 50 action accept # set ipv4 input filter rule 50 source address 127.0.0.0/8 # top
應用及儲存
1 2 3 4 5 6
# # 應用 # commit # # 儲存(寫入到開機設定) # save # # 也可簡化為底下 # # commit; save