Using VyOS as a Firewall



Similar documents
CSC574 - Computer and Network Security Module: Firewalls

CS Computer and Network Security: Firewalls

CS Computer and Network Security: Firewalls

CSE543 - Computer and Network Security Module: Firewalls

How To Set Up An Ip Firewall On Linux With Iptables (For Ubuntu) And Iptable (For Windows)

Firewall. Vyatta System. REFERENCE GUIDE IPv4 Firewall IPv6 Firewall Zone Based Firewall VYATTA, INC.

Module: Firewalls. Professor Patrick McDaniel Spring CMPSC443 - Introduction to Computer and Network Security

Linux Firewall Wizardry. By Nemus

Firewall. Vyatta System. REFERENCE GUIDE IPv4 Firewall IPv6 Firewall Zone Based Firewall VYATTA, INC.

1:1 NAT in ZeroShell. Requirements. Overview. Network Setup

Track 2 Workshop PacNOG 7 American Samoa. Firewalling and NAT

CIS 433/533 - Computer and Network Security Firewalls

Firewall Testing. Cameron Kerr Telecommunications Programme University of Otago. May 16, 2005

Firewalls. Chien-Chung Shen

Intro to Linux Kernel Firewall

Evaluation guide. Vyatta Quick Evaluation Guide

PFSENSE Load Balance with Fail Over From Version Beta3

Configuring IP Load Sharing in AOS Quick Configuration Guide

TECHNICAL NOTES. Security Firewall IP Tables

Linux: 20 Iptables Examples For New SysAdmins

Definition of firewall

Linux Firewall. Linux workshop #2.

CIT 480: Securing Computer Systems. Firewalls

Chapter 4 Customizing Your Network Settings

Chapter 4 Customizing Your Network Settings

Load Balance Router R258V

High Availability. Vyatta System

Firewall REFERENCE GUIDE. VYATTA, INC. Vyatta System. IPv4 Firewall IPv6 Firewall Zone-Based Firewall. Title

Firewalls. Pehr Söderman KTH-CSC

Netfilter. GNU/Linux Kernel version 2.4+ Setting up firewall to allow NIS and NFS traffic. January 2008

How To Set Up A Network Map In Linux On A Ubuntu 2.5 (Amd64) On A Raspberry Mobi) On An Ubuntu (Amd66) On Ubuntu 4.5 On A Windows Box

Optimisacion del ancho de banda (Introduccion al Firewall de Linux)

The SpeedTouch and Firewalling

Smart Tips. Enabling WAN Load Balancing. Key Features. Network Diagram. Overview. Featured Products. WAN Failover. Enabling WAN Load Balancing Page 1

Lab Organizing CCENT Objectives by OSI Layer

Polycom. RealPresence Ready Firewall Traversal Tips

Linux firewall. Need of firewall Single connection between network Allows restricted traffic between networks Denies un authorized users

Quick Note 53. Ethernet to W-WAN failover with logical Ethernet interface.

Firewalls, NAT and Intrusion Detection and Prevention Systems (IDS)

About Firewall Protection

Linux Server Support by Applied Technology Research Center. Proxy Server Configuration

Project 4: IP over DNS Due: 11:59 PM, Dec 14, 2015

Open Source Firewall

Introduction to Firewalls Open Source Security Tools for Information Technology Professionals

CIT 480: Securing Computer Systems. Firewalls

Packet filtering with Linux

Firewall. IPTables and its use in a realistic scenario. José Bateira ei10133 Pedro Cunha ei05064 Pedro Grilo ei09137 FEUP MIEIC SSIN

Infoblox vnios Software for CISCO AXP

Network Security Management

Internet Firewall CSIS Packet Filtering. Internet Firewall. Examples. Spring 2011 CSIS net15 1. Routers can implement packet filtering

A host-based firewall can be used in addition to a network-based firewall to provide multiple layers of protection.

Recommended IP Telephony Architecture

Linux Routers and Community Networks

Next Generation Network Firewall

Protecting and controlling Virtual LANs by Linux router-firewall

Cisco PIX vs. Checkpoint Firewall

Digi Certified Transport Technician Training Course (DCTT)

Chapter 7. Firewalls

PowerLink Bandwidth Aggregation Redundant WAN Link and VPN Fail-Over Solutions

Manage a Firewall Using your Plesk Control Panel Contents

Application Note - Using Tenor behind a Firewall/NAT

Guardian Digital WebTool Firewall HOWTO. by Pete O Hara

How To Block On A Network With A Group Control On A Router On A Linux Box On A Pc Or Ip Access Group On A Pnet 2 On A 2G Router On An Ip Access-Group On A Ip Ip-Control On A Net

Firewall REFERENCE GUIDE. VYATTA, INC. Vyatta System. IPv4 Firewall IPv6 Firewall Zone-Based Firewall. Title

Firewalls with IPTables. Jason Healy, Director of Networks and Systems

Main functions of Linux Netfilter

Ranch Networks for Hosted Data Centers

CMPT 471 Networking II

Lab Objectives & Turn In

Firewall VPN Router. Quick Installation Guide M73-APO09-380

+ iptables. packet filtering && firewall

ACADEMIA LOCAL CISCO UCV-MARACAY CONTENIDO DE CURSO CURRICULUM CCNA. SEGURIDAD SEGURIDAD EN REDES. NIVEL I. VERSION 2.0

shortcut Tap into learning NOW! Visit for a complete list of Short Cuts. Your Short Cut to Knowledge

Document No. FO1101 Issue Date: Work Group: FibreOP Technical Team October 31, 2013 FINAL:

Netfilter / IPtables

Configuring SSL VPN on the Cisco ISA500 Security Appliance

Troubleshooting the Firewall Services Module

Secure use of iptables and connection tracking helpers

SonicWALL PCI 1.1 Implementation Guide

Configuring the Transparent or Routed Firewall

MULTI WAN TECHNICAL OVERVIEW

Firewall. FortiOS Handbook v3 for FortiOS 4.0 MR3

High Availability. Vyatta System

EdgeRouter Lite 3-Port Router. Datasheet. Model: ERLite-3. Sophisticated Routing Features. Advanced Security, Monitoring, and Management

Manuale Turtle Firewall

Magnum Network Software DX

Federal Computer Incident Response Center (FedCIRC) Defense Tactics for Distributed Denial of Service Attacks

Configuring a LAN SIParator. Lisa Hallingström Paul Donald Bogdan Musat Adnan Khalid Per Johnsson Rickard Nilsson

Southwest Arkansas Telephone Cooperative Network Management Practices

Note: This case study utilizes Packet Tracer. Please see the Chapter 5 Packet Tracer file located in Supplemental Materials.

Firewall Defaults, Public Server Rule, and Secondary WAN IP Address

Fault tolerant stateful firewalling with GNU/Linux. Pablo Neira Ayuso Proyecto Netfilter University of Sevilla

2.5 TECHNICAL NOTE FTP

Deployment Topologies

Project 2: Firewall Design (Phase I)

co Characterizing and Tracing Packet Floods Using Cisco R

Troubleshooting the Firewall Services Module

How to Secure RHEL 6.2 Part 2

Chapter 9 Monitoring System Performance

Transcription:

Copyright 2015, Ray Patrick Soucy Verbatim copying and distribution permitted provided this notice is preserved. Using VyOS as a Firewall Disclaimer: This guide will provide a technical deep-dive into VyOS as a firewall and assumes basic knowledge of networking, firewalls, Linux and Netfilter, as well as VyOS CLI and configuration basics. This guide was written in hopes that it will be useful to others and makes no claim of responsibility for security incidents related to advice in this document. USE AT YOUR OWN RISK. To learn more about VyOS, visit the project website at vyos.net. PROLOGUE For us, open source isn't just a business model; it's smart engineering practice. Bruce Schneier Argument 1: Open Source as a requirement for Security Infrastructure In 2013, Edward Snowden, an Infrastructure Analyst working for Booz Allen Hamilton, a US defense contractor, and assigned to the NSA, provided the public with classified information detailing the extent of NSA programs used to compromise security infrastructure, including the use of backdoors on major network firewall platforms. The list of platforms specifically cited include offerings from Cisco, Juniper, and Huawei. A major concern following these revelations, was not only the ability to trust the integrity of security infrastructure, but also in the perceived disregard or arrogance demonstrated by the NSA in the assumption that these tools or details on how to exploit them would not fall into the purview of bad actors. As a direct result of these events there is a growing sense within the security community that access to source code is a requirement for security. Argument 2: Addressing Performance Concerns In the past there were performance limitations that prevented the use of software-based solutions for network infrastructure. - 1 of 15 -

Today provides much more flexibility. Using modern hardware, Linux-based systems are able to provide a viable solution for throughput needs in the multi- Gigabit realm, easily reaching the 2M pps target for line-rate Gigabit at 64-byte packets. This performance is quickly growing thanks to efforts like Intel DPDK which pushes Linux-based systems into the multi- Ten Gigabit area for packet processing (100M pps and beyond). While there are no open source implementations of DPDK-accelerated Linux today, it does show promise for scaling Linux-based network infrastructure, and proprietary Vyatta vrouter 5600 from Brocade purports to do just that through their vplane technology, though still in early stages of implementation, it does provide encouragement as a growth option until the FOSS community can catch up. Argument 3: Security through Consistency As VyOS is designed to run on x86 architecture, it presents one of the first firewall solutions that allows for hardware to truly be right-sized independent of OS or CLI. VyOS can not only be run on a wide range of physical hardware, but also as a virtual instance allowing for NFV (network function virtualization) applications. The use of one OS and one CLI across firewall solutions within an organization significantly reduces the complexity of the creation and audit of policy and mitigates the human error in policy creation as a result of having to master multiple configuration syntaxes and platforms. The majority of security incidents can be linked back to configuration error. The human-readable and verbose configuration syntax of VyOS presents clear policy definition that can easily be understood by security professionals without specific knowledge of the platform. The image-based install process of VyOS allows for new releases to be installed in a non-destructive way. While many solutions share a configuration that may be altered through the upgrade process, VyOS maintains a separate copy of its configuration for each image, allowing for changes to be reverted without the risk of backward-incompatibility. Finally the unified, human-readable and text-based, configuration file of VyOS allows for configuration to be backed up using standard revision control systems. Operationally these design choices promote the maintenance and operation of VyOS to significantly improve the overall security posture of an organization. Argument 4: Total Cost of Ownership The CapEx component of VyOS is a clear winner. The OS is zero-cost and the hardware can be right-sized to application requirements. A common fear associated with the use of Linux for network and security infrastructure is the out of control OpEx component due to the number of unknowns. The answer to this is that VyOS is not simply a Linux distribution with network and firewall functionality, but a modern network operating system with a consistent CLI and configuration syntax, and clear upgrade process. As a result the OpEx component of VyOS can be considered equivalent to a Cisco or Juniper solution. - 2 of 15 -

Part 1: Dive Deep, VyOS Internals and Linux Netfilter The firewall for VyOS is powered by Linux Netfilter (more commonly known by it s user-space utility iptables ). Netfilter is one of the most widely adopted and peer-reviewed firewall implementations in the world. Firewall policy in VyOS can be applied using two methods: Per-Interface or Zone Policy. This guide will use the more common per-interface policy. For per-interface, policy can be applied to an interface in three directions, in, out, and local. For those familiar with Linux Netfilter it is important not to confuse in for the INPUT chain of iptables. The in policy is instead applied to traffic received being forwarded through the interface, representing the FORWARD chain in iptables specific to the interface, e.g. -i for incoming. Similarly, the out direction is also matched using the FORWARD chain but using -o for outgoing instead. Finally, the local policy actually represents the INPUT chain with the -i flag set to the interface being configured. Firewall rules can reference group objects (implemented using the ipsets sub-project of Netfilter). The group types supported are network, address, and port. The network group object is implemented as a hash:net ipset. The address group object as hash:ip. And the port group object as bitmap:port. Each named policy is implemented as a chain in iptables. Consider the following example: setfirewallnameinside-localdefault-action'drop' Generates the following iptables commands: -NINSIDE-LOCAL -AINSIDE-LOCAL-mcomment--comment"INSIDE-LOCAL-10000default-actiondrop"-jDROP And applying the policy to an interface eth0 : setinterfacesbondingeth0firewalllocalname'inside-local' The following: -AVYATTA_FW_LOCAL_HOOK-ieth0-jINSIDE-LOCAL One thing to note is that the accept action in a firewall rule will be implemented as RETURN which jumps back to the parent chain for further processing. VyOS implements the following policy by default: -NVYATTA_FW_IN_HOOK -NVYATTA_FW_LOCAL_HOOK -NVYATTA_FW_OUT_HOOK -NVYATTA_POST_FW_FWD_HOOK - 3 of 15 -

-NVYATTA_POST_FW_IN_HOOK -NVYATTA_POST_FW_OUT_HOOK -NVYATTA_PRE_FW_FWD_HOOK -NVYATTA_PRE_FW_IN_HOOK -NVYATTA_PRE_FW_OUT_HOOK -AVYATTA_POST_FW_FWD_HOOK-jACCEPT -AVYATTA_POST_FW_IN_HOOK-jACCEPT -AVYATTA_POST_FW_OUT_HOOK-jACCEPT -AVYATTA_PRE_FW_FWD_HOOK-jRETURN -AVYATTA_PRE_FW_IN_HOOK-jRETURN -AVYATTA_PRE_FW_OUT_HOOK-jRETURN -AINPUT-jVYATTA_PRE_FW_IN_HOOK -AINPUT-jVYATTA_FW_LOCAL_HOOK -AINPUT-jVYATTA_POST_FW_IN_HOOK -AFORWARD-jVYATTA_PRE_FW_FWD_HOOK -AFORWARD-jVYATTA_FW_IN_HOOK -AFORWARD-jVYATTA_FW_OUT_HOOK -AFORWARD-jVYATTA_POST_FW_FWD_HOOK -AOUTPUT-jVYATTA_PRE_FW_OUT_HOOK -AOUTPUT-jVYATTA_POST_FW_OUT_HOOK The pre and post hooks exist for internal policy rules (such as the final accept) while the majority of filtering is applied using VYATTA_FW_LOCAL_HOOK for local, VYATTA_FW_IN_HOOK for in, and VYATTA_FW_OUT_HOOK for out. This model of using the RETURN target in place of ACCEPT to allow further processing if needed restricts the ability for VyOS to support firewall rules referencing an additional policy as a target (or jumping to another chain). To those experienced with Netfilter, this may seem overly restrictive, but it does have a side-effect of enforcing simple, easy-to-read, policy which improves overall security posture by reducing human error or oversight. An important aspect of VyOS as a firewall which differentiates itself from other Linux-based options is that firewall changes are dynamic in nature. A typical Linux-based firewall will flush all chains and tables then rebuild policy to implement changes. This not only has the undesired effect of zeroing counters, but can introduce a race-condition for firewalls where the delay between removing and reinserting rules may apply inconsistent or incomplete policy to traffic and potentially trigger connection tracking to mark a flow as invalid. To avoid this, VyOS only modifies rules that are modified in the configuration system. This means that changes to even large policy rules are non-destructive and will not alter traffic flow matched by other rules. This is especially true if used for stateful packet inspection and a policy to accept established traffic is in use allowing policy changes to be made in production. - 4 of 15 -

A consequence of this model is that manual configuration of iptables can place the system into an inconsistent state where the expected system state from a configuration standpoint does not match the actual Netfilter policy in place. For this reason you should never invoke Netfilter tools such as iptables or ipset directly. Part 2: Configuration By Example We learned in the previous section that policy is defined as a named set of firewall rules and applied to a network interface for a direction ( in, out, or local ). In this section we ll take a look at a basic firewall configuration to build a typical firewall configuration. A standard three zone firewall is assumed outside or WAN on interface eth0, inside or LAN on eth1, and a DMZ on eth2. Traffic for the LAN will use private IP addressing and NAT. Traffic for the DMZ will use public IP addressing. Traffic from the LAN to the DMZ will be permitted by default. Traffic from the DMZ to the LAN will be dropped by default. Traffic from the WAN will be dropped by default. The IP networks used will be: WAN: 198.51.100.0/29 LAN: 10.1.0.0/24 DMZ: 203.0.113.0/24 Our basic starting interface configuration will be as follows: setinterfacesetherneteth0description'wan' setinterfacesetherneteth0address'198.51.100.6/29' setinterfacesetherneteth1description'lan' setinterfacesetherneteth1address'10.1.0.1/24' setinterfacesetherneteth2description'dmz' setinterfacesetherneteth2address'203.0.113.1/24' setprotocolsstaticroute0.0.0.0/0next-hop'198.51.100.1' Our first goal will be to create local policy for traffic destined to the firewall itself. There are two ways we can handle stateful packet inspection. The first and easier method is to set the global firewall state policy: setfirewallstate-policyestablishedaction'accept' setfirewallstate-policyrelatedaction'accept' setfirewallstate-policyinvalidaction'drop' - 5 of 15 -

This will be implemented using the pre hook chains discussed in the previous section and applied before any user-defined rules are processed. The three states are matched against the Linux conntrack table which is used to implement stateful packet inspection in Netfilter. The second option is to define state rules in each policy. The advantage of doing so is the ability to filter before the state check. For example you may wish to add logging of matched packets for a particular state for troubleshooting or you may wish to blacklist traffic before its connection state is evaluated. We will opt to use manual method in this example. Before we create our firewall policy, there are a few group objects we will want in place so they can be referenced: A network group for each of the 3 networks (WAN, LAN, and DMZ). A network group for systems authorized to manage the firewall (SSH and SNMP). A network group of blacklisted hosts or networks. setfirewallgroupnetwork-groupnet-blacklistednetwork'1.1.1.1/32' setfirewallgroupnetwork-groupnet-dmznetwork'203.0.113.0/24' setfirewallgroupnetwork-groupnet-lannetwork'10.1.0.0/24' setfirewallgroupnetwork-groupnet-managementnetwork'10.1.0.10/32' setfirewallgroupnetwork-groupnet-managementnetwork'10.1.0.11/32' setfirewallgroupnetwork-groupnet-wannetwork'198.51.100.0/24' Note that we can reference individual IP addresses as part of a network group object by using a prefix-length of 32. Next we will create a named local policy for each interface: setfirewallnamewan-localdefault-action'drop' setfirewallnamewan-localrule1000action'drop' setfirewallnamewan-localrule1000sourcegroupnetwork-group'net-blacklisted' setfirewallnamewan-localrule1010action'accept' setfirewallnamewan-localrule1010stateestablished'enable' setfirewallnamewan-localrule1010staterelated'enable' setfirewallnamewan-localrule1011action'drop' setfirewallnamewan-localrule1011stateinvalid'enable' setfirewallnamewan-localrule1020action'accept' setfirewallnamewan-localrule1020icmptype-name'echo-request' setfirewallnamewan-localrule1020protocol'icmp' setfirewallnamewan-localrule1020statenew'enable' setfirewallnamewan-localrule1100action'drop' setfirewallnamewan-localrule1100destinationport'22' setfirewallnamewan-localrule1100protocol'tcp' setfirewallnamewan-localrule1100recentcount'4' setfirewallnamewan-localrule1100recenttime'60' setfirewallnamewan-localrule1100sourcegroupnetwork-group'net-management' setfirewallnamewan-localrule1100statenew'enable' - 6 of 15 -

setfirewallnamewan-localrule1101action'accept' setfirewallnamewan-localrule1101destinationport'22' setfirewallnamewan-localrule1101protocol'tcp' setfirewallnamewan-localrule1101sourcegroupnetwork-group'net-management' setfirewallnamewan-localrule1101statenew'enable' setfirewallnamewan-localrule1110action'accept' setfirewallnamewan-localrule1110destinationport'161' setfirewallnamewan-localrule1110protocol'udp' setfirewallnamewan-localrule1110sourcegroupnetwork-group'net-management' setfirewallnamewan-localrule1110statenew'enable' setfirewallnamelan-localdefault-action'drop' setfirewallnamelan-localrule1000action'drop' setfirewallnamelan-localrule1000sourcegroupnetwork-group'net-blacklisted' setfirewallnamelan-localrule1010action'accept' setfirewallnamelan-localrule1010stateestablished'enable' setfirewallnamelan-localrule1010staterelated'enable' setfirewallnamelan-localrule1011action'drop' setfirewallnamelan-localrule1011stateinvalid'enable' setfirewallnamelan-localrule1020action'accept' setfirewallnamelan-localrule1020icmptype-name'echo-request' setfirewallnamelan-localrule1020protocol'icmp' setfirewallnamelan-localrule1020statenew'enable' setfirewallnamelan-localrule1030action'accept' setfirewallnamelan-localrule1030destinationport'67' setfirewallnamelan-localrule1030protocol'udp' setfirewallnamelan-localrule1030statenew'enable' setfirewallnamelan-localrule1040action'accept' setfirewallnamelan-localrule1040destinationport'53' setfirewallnamelan-localrule1040protocol'tcp_udp' setfirewallnamelan-localrule1040statenew'enable' setfirewallnamelan-localrule1050action'accept' setfirewallnamelan-localrule1050destinationport'123' setfirewallnamelan-localrule1050protocol'udp' setfirewallnamelan-localrule1050statenew'enable' setfirewallnamelan-localrule1100action'drop' setfirewallnamelan-localrule1100destinationport'22' setfirewallnamelan-localrule1100protocol'tcp' setfirewallnamelan-localrule1100recentcount'4' setfirewallnamelan-localrule1100recenttime'60' setfirewallnamelan-localrule1100sourcegroupnetwork-group'net-management' setfirewallnamelan-localrule1100statenew'enable' setfirewallnamelan-localrule1101action'accept' setfirewallnamelan-localrule1101destinationport'22' setfirewallnamelan-localrule1101protocol'tcp' setfirewallnamelan-localrule1101sourcegroupnetwork-group'net-management' setfirewallnamelan-localrule1101statenew'enable' setfirewallnamelan-localrule1110action'accept' - 7 of 15 -

setfirewallnamelan-localrule1110destinationport'161' setfirewallnamelan-localrule1110protocol'udp' setfirewallnamelan-localrule1110sourcegroupnetwork-group'net-management' setfirewallnamelan-localrule1110statenew'enable' setfirewallnamedmz-localdefault-action'drop' setfirewallnamedmz-localrule1000action'drop' setfirewallnamedmz-localrule1000sourcegroupnetwork-group'net-blacklisted' setfirewallnamedmz-localrule1010action'accept' setfirewallnamedmz-localrule1010stateestablished'enable' setfirewallnamedmz-localrule1010staterelated'enable' setfirewallnamedmz-localrule1011action'drop' setfirewallnamedmz-localrule1011stateinvalid'enable' setfirewallnamedmz-localrule1020action'accept' setfirewallnamedmz-localrule1020icmptype-name'echo-request' setfirewallnamedmz-localrule1020protocol'icmp' setfirewallnamedmz-localrule1020statenew'enable' setfirewallnamedmz-localrule1030action'accept' setfirewallnamedmz-localrule1030destinationport'67' setfirewallnamedmz-localrule1030protocol'udp' setfirewallnamedmz-localrule1030statenew'enable' setfirewallnamedmz-localrule1040action'accept' setfirewallnamedmz-localrule1040destinationport'53' setfirewallnamedmz-localrule1040protocol'tcp_udp' setfirewallnamedmz-localrule1040statenew'enable' setfirewallnamedmz-localrule1050action'accept' setfirewallnamedmz-localrule1050destinationport'123' setfirewallnamedmz-localrule1050protocol'udp' setfirewallnamedmz-localrule1050statenew'enable' setfirewallnamedmz-localrule1100action'drop' setfirewallnamedmz-localrule1100destinationport'22' setfirewallnamedmz-localrule1100protocol'tcp' setfirewallnamedmz-localrule1100recentcount'4' setfirewallnamedmz-localrule1100recenttime'60' setfirewallnamedmz-localrule1100sourcegroupnetwork-group'net-management' setfirewallnamedmz-localrule1100statenew'enable' setfirewallnamedmz-localrule1101action'accept' setfirewallnamedmz-localrule1101destinationport'22' setfirewallnamedmz-localrule1101protocol'tcp' setfirewallnamedmz-localrule1101sourcegroupnetwork-group'net-management' setfirewallnamedmz-localrule1101statenew'enable' setfirewallnamedmz-localrule1110action'accept' setfirewallnamedmz-localrule1110destinationport'161' setfirewallnamedmz-localrule1110protocol'udp' setfirewallnamedmz-localrule1110sourcegroupnetwork-group'net-management' setfirewallnamedmz-localrule1110statenew'enable' The above policy is similar for each interface: - 8 of 15 -

1. Drop blacklisted traffic 2. State Policy (accept established,related; drop invalid) 3. Accept ICMP echo-request (ping) 4. Accept DHCP request 5. Accept DNS requests 6. Accept NTP requests 7. Limit SSH connections to 3 per minute per IP address and accept SSH from management networks 8. Accept SNMP from management networks The difference for the WAN interface is that we exclude exceptions to permit DHCP, DNS, and NTP traffic since we only provide these services to the LAN and DMZ. Next we apply the policy to each interface: setinterfacesetherneteth0firewalllocalname'wan-local' setinterfacesetherneteth1firewalllocalname'lan-local' setinterfacesetherneteth2firewalllocalname'dmz-local' At this point the firewall itself is secure and allows management access from 10.1.0.10 and 10.1.0.11 (defined in our NET-MANAGEMENT network group object) and the 1.1.1.1 address is blacklisted to the firewall. We still need to filter traffic between networks, however. For filtering traffic through the firewall it s recommended to filter in the in and out direction for local networks (e.g. LAN and DMZ) but not filter on the uplink interface (WAN). A common mistake is to filter on both the WAN and LAN interface which creates redundant policy. As the need for additional internal interfaces grow over time so does the size and complexity of a WAN policy. First we ll create the default incoming policy. This will match outgoing traffic from the client perspective. For our LAN we will permit all outgoing traffic by default. For our DMZ we will deny all outgoing traffic by default. setfirewallnamelan-indefault-action'drop' setfirewallnamelan-inrule1000action'drop' setfirewallnamelan-inrule1000sourcegroupnetwork-group'net-blacklisted' setfirewallnamelan-inrule1001action'drop' setfirewallnamelan-inrule1001destinationgroupnetwork-group'net-blacklisted' setfirewallnamelan-inrule1010action'accept' setfirewallnamelan-inrule1010stateestablished'enable' setfirewallnamelan-inrule1010staterelated'enable' setfirewallnamelan-inrule1011action'drop' setfirewallnamelan-inrule1011stateinvalid'enable' setfirewallnamelan-inrule9000action'accept' setfirewallnamelan-inrule9000sourcegroupnetwork-group'net-lan' setfirewallnamelan-inrule9000statenew'enable' setfirewallnamedmz-indefault-action'drop' - 9 of 15 -

setfirewallnamedmz-inrule1000action'drop' setfirewallnamedmz-inrule1000sourcegroupnetwork-group'net-blacklisted' setfirewallnamedmz-inrule1001action'drop' setfirewallnamedmz-inrule1001destinationgroupnetwork-group'net-blacklisted' setfirewallnamedmz-inrule1010action'accept' setfirewallnamedmz-inrule1010stateestablished'enable' setfirewallnamedmz-inrule1010staterelated'enable' setfirewallnamedmz-inrule1011action'drop' setfirewallnamedmz-inrule1011stateinvalid'enable' Note that we drop blacklisted traffic in both directions (as a source and as a destination). This allows us to use the blacklist group object to filter internal systems as well as external systems. For the DMZ policy we simply omit the rule to permit traffic sourced from the local network. Apply these policies to their interfaces: setinterfacesetherneteth1firewallinname'lan-in' setinterfacesetherneteth2firewallinname'dmz-in' Next we ll look to create the outgoing policy for the LAN and DMZ. This will be inbound traffic from the client perspective. Here we will create a policy to permit all traffic to the DMZ from the LAN network as well as a rule to permit traffic to a web server at 203.0.113.100. setfirewallnamelan-outdefault-action'drop' setfirewallnamelan-outrule1000action'drop' setfirewallnamelan-outrule1000sourcegroupnetwork-group'net-blacklisted' setfirewallnamelan-outrule1001action'drop' setfirewallnamelan-outrule1001destinationgroupnetwork-group'net-blacklisted' setfirewallnamelan-outrule1010action'accept' setfirewallnamelan-outrule1010stateestablished'enable' setfirewallnamelan-outrule1010staterelated'enable' setfirewallnamelan-outrule1011action'drop' setfirewallnamelan-outrule1011stateinvalid'enable' setfirewallnamelan-outrule1020action'accept' setfirewallnamelan-outrule1020icmptype-name'echo-request' setfirewallnamelan-outrule1020protocol'icmp' setfirewallnamelan-outrule1020statenew'enable' setfirewallnamedmz-outdefault-action'drop' setfirewallnamedmz-outrule1000action'drop' setfirewallnamedmz-outrule1000sourcegroupnetwork-group'net-blacklisted' setfirewallnamedmz-outrule1001action'drop' setfirewallnamedmz-outrule1001destinationgroupnetwork-group'net-blacklisted' setfirewallnamedmz-outrule1010action'accept' setfirewallnamedmz-outrule1010stateestablished'enable' setfirewallnamedmz-outrule1010staterelated'enable' setfirewallnamedmz-outrule1011action'drop' - 10 of 15 -

setfirewallnamedmz-outrule1011stateinvalid'enable' setfirewallnamedmz-outrule1020action'accept' setfirewallnamedmz-outrule1020icmptype-name'echo-request' setfirewallnamedmz-outrule1020protocol'icmp' setfirewallnamedmz-outrule1020statenew'enable' setfirewallnamedmz-outrule1100action'accept' setfirewallnamedmz-outrule1100sourcegroupnetwork-group'net-lan' setfirewallnamedmz-outrule1100statenew'enable' setfirewallnamedmz-outrule4000action'accept' setfirewallnamedmz-outrule4000destinationaddress'203.0.113.100' setfirewallnamedmz-outrule4000destinationport'80,443' setfirewallnamedmz-outrule4000protocol'tcp' setfirewallnamedmz-outrule4000statenew'enable' Finally we apply these to their interfaces: setinterfacesetherneteth1firewalloutname'lan-out' setinterfacesetherneteth2firewalloutname'dmz-out' Traffic filtering is now in place. For better accounting, there are some logging options that can be enabled. The first is to log configuration changes (recommended): setfirewallconfig-trap'enable' The next option is to log traffic that reaches the default rule of a named policy (in our case the default drop). Take care as this can generate quite a bit of logging. A remote syslog server is strongly encouraged. setfirewallnamelan-in'enable-default-log' setfirewallnamelan-out'enable-default-log' setfirewallnamedmz-in'enable-default-log' setfirewallnamedmz-out'enable-default-log' For any individual rule, logging can also be enabled. In this example we want to log traffic dropped due to an invalid conntrack state: setfirewallnamelan-inrule1011log'enable' setfirewallnamelan-outrule1011log'enable' setfirewallnamedmz-inrule1011log'enable' setfirewallnamedmz-outrule1011log'enable' Finally, the following global configuration defaults are recommended: setfirewallall-ping'enable' setfirewallbroadcast-ping'disable' setfirewallipv6-receive-redirects'disable' setfirewallipv6-src-route'disable' setfirewallip-src-route'disable' - 11 of 15 -

setfirewalllog-martians'enable' setfirewallreceive-redirects'disable' setfirewallsend-redirects'disable' setfirewallsource-validation'disable' setfirewallsyn-cookies'enable' The last step is to configure NAT, in this case we will NAT LAN traffic to the IP of our WAN interface. setnatsourcerule1000outbound-interface'eth0' setnatsourcerule1000sourceaddress'10.1.0.0/24' setnatsourcerule1000translationaddress'198.51.100.6' Note that more detailed NAT configuration (including port-forwards or 1:1 NAT) is beyond the scope of this guide. - 12 of 15 -

Part 3: High Availability and Scaling Considerations In the previous section we discussed how to configure VyOS as a firewall. In this section we will build on the previous configuration to configure a pair of VyOS firewalls for High Availability. VyOS supports two methods of HA, Clustering and Manual VRRP. Clustering was a relatively new feature introduced in Vyatta before the VyOS project was started and as a result is not yet feature complete. Most noticeably a configuration-sync mechanism is absent. As a result, the current preferred method of HA in VyOS is the use of VRRP and conntrack-sync (connection state table sharing), and will be the method covered by this guide. Assuming you have a pair of VyOS systems, each with 4 ethernet ports, and the configuration used for the previous example, our first step will be to establish a peer-link to the secondary unit. The peer-link only exists between VyOS systems and should be a direct connection. As such, we will use a bogon IP address for the link network of 192.0.0.1/30 for the primary, and 192.0.0.2/30 for the secondary as to avoid addressing conflicts with RFC 1918private address space. Note that use of this addressing is in violation of RFC 5736 and currently allocated by RFC 7335 and may not be suitable for your environment. Alternatively any RFC 1918 prefix can be used. On the primary: setinterfacesetherneteth3description'peer-link' setinterfacesetherneteth3address'192.0.0.1/30' Secondary: setinterfacesetherneteth3description'peer-link' setinterfacesetherneteth3address'192.0.0.2/30' Next we will configure the conntrack-sync service to make use of this link to share the connection state table. This will provide the secondary firewall with the ability to know if traffic was previously established or not in the event of failover. On both Primary and Secondary: setserviceconntrack-syncevent-listen-queue-size'8' setserviceconntrack-syncfailover-mechanismvrrpsync-group'cluster-1' setserviceconntrack-syncinterface'eth3' setserviceconntrack-syncmcast-group'225.0.0.50' setserviceconntrack-syncsync-queue-size'1' Finally, we will re-configure each network interface (WAN, LAN, DMZ) to use VRRP for failover. Note that VRRP will require 3 IP addresses per network; one for each firewall and a shared virtual IP. On the Primary: - 13 of 15 -

setinterfacesetherneteth0address'198.51.100.4/29' setinterfacesetherneteth0vrrpvrrp-group10advertise-interval'1' setinterfacesetherneteth0vrrpvrrp-group10preempt'true' setinterfacesetherneteth0vrrpvrrp-group10preempt-delay'300' setinterfacesetherneteth0vrrpvrrp-group10priority'128' setinterfacesetherneteth0vrrpvrrp-group10'rfc3768-compatibility' setinterfacesetherneteth0vrrpvrrp-group10sync-group'cluster-1' setinterfacesetherneteth0vrrpvrrp-group10virtual-address'198.51.100.6/29' setinterfacesetherneteth1address'10.1.0.2/24' setinterfacesetherneteth1vrrpvrrp-group11advertise-interval'1' setinterfacesetherneteth1vrrpvrrp-group11preempt'true' setinterfacesetherneteth1vrrpvrrp-group11preempt-delay'300' setinterfacesetherneteth1vrrpvrrp-group11priority'128' setinterfacesetherneteth1vrrpvrrp-group11'rfc3768-compatibility' setinterfacesetherneteth1vrrpvrrp-group11sync-group'cluster-1' setinterfacesetherneteth1vrrpvrrp-group11virtual-address'10.1.0.1/24' setinterfacesetherneteth2address'203.0.113.2/24' setinterfacesetherneteth2vrrpvrrp-group12advertise-interval'1' setinterfacesetherneteth2vrrpvrrp-group12preempt'true' setinterfacesetherneteth2vrrpvrrp-group12preempt-delay'300' setinterfacesetherneteth2vrrpvrrp-group12priority'128' setinterfacesetherneteth2vrrpvrrp-group12'rfc3768-compatibility' setinterfacesetherneteth2vrrpvrrp-group12sync-group'cluster-1' setinterfacesetherneteth2vrrpvrrp-group12virtual-address'203.0.113.1/24' On the Secondary: setinterfacesetherneteth0address'198.51.100.5/29' setinterfacesetherneteth0vrrpvrrp-group10advertise-interval'1' setinterfacesetherneteth0vrrpvrrp-group10preempt'true' setinterfacesetherneteth0vrrpvrrp-group10preempt-delay'300' setinterfacesetherneteth0vrrpvrrp-group10priority'64' setinterfacesetherneteth0vrrpvrrp-group10'rfc3768-compatibility' setinterfacesetherneteth0vrrpvrrp-group10sync-group'cluster-1' setinterfacesetherneteth0vrrpvrrp-group10virtual-address'198.51.100.6/29' setinterfacesetherneteth1address'10.1.0.3/24' setinterfacesetherneteth1vrrpvrrp-group11advertise-interval'1' setinterfacesetherneteth1vrrpvrrp-group11preempt'true' setinterfacesetherneteth1vrrpvrrp-group11preempt-delay'300' setinterfacesetherneteth1vrrpvrrp-group11priority'64' setinterfacesetherneteth1vrrpvrrp-group11'rfc3768-compatibility' setinterfacesetherneteth1vrrpvrrp-group11sync-group'cluster-1' setinterfacesetherneteth1vrrpvrrp-group11virtual-address'10.1.0.1/24' - 14 of 15 -

setinterfacesetherneteth2address'203.0.113.3/24' setinterfacesetherneteth2vrrpvrrp-group12advertise-interval'1' setinterfacesetherneteth2vrrpvrrp-group12preempt'true' setinterfacesetherneteth2vrrpvrrp-group12preempt-delay'300' setinterfacesetherneteth2vrrpvrrp-group12priority'64' setinterfacesetherneteth2vrrpvrrp-group12'rfc3768-compatibility' setinterfacesetherneteth2vrrpvrrp-group12sync-group'cluster-1' setinterfacesetherneteth2vrrpvrrp-group12virtual-address'203.0.113.1/24' The configuration above will delay recovery of the primary by 5 minutes (300 seconds) to allow for re-building of the conntrack state table. For larger systems you may want to configure the system ARP table to support more address space. setsystemiparptable-size'32768' You should also consider configuration of conntrack if the system will be responsible for a large number of flows. setsystemconntrackexpect-table-size'8192' setsystemconntrackhash-size'131072' setsystemconntracktable-size'1048576' Finally, you may find it helpful to disable certain conntrack helper modules known to be problematic: setsystemconntrackmodulesnfs'disable' setsystemconntrackmodulessip'disable' setsystemconntrackmodulessqlnet'disable' At this point you should have a highly available pair, allowing for in-service upgrades and maintenance. Take care to make sure you replicate firewall configuration on each firewall so that they re consistent in the event of failover. - 15 of 15 -