Skip to content

Commit

Permalink
tried to translate a lot of Dutch comments into English
Browse files Browse the repository at this point in the history
  • Loading branch information
basdusee committed Nov 29, 2017
1 parent 3ab3b7b commit cb31089
Show file tree
Hide file tree
Showing 14 changed files with 957 additions and 42 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
# Vagrant run stuff #
#####################
.vagrant
.gitignore
63 changes: 34 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,41 @@
# Virtuele DIY Linux routers!
Dit is een vingeroefening in Vagrant om een setje Linux routers op te spinnen en te kijken of hiermee de functionaliteit van bijvoorbeeld de NSX Edge is te benaderen. Ook zou zoiets gebruikt kunnen worden waar anders Vyatta o.i.d. toegepast wordt.

Waarom deze? Voordeel van een DIY router is de vrijheid in maatwerk en daarmee flexibiliteit van de oplossing. Nadeel is het volledige gebrek aan support en daarmee ook het eigenhandig uitvoeren van het onderhoud.

## Installatie
Wat heb je nodig om los te gaan met deze spullen?
* Installeer Vagrant
* Installeer Virtualbox
* git clone https://code.ogdsoftware.nl/bas.dusee/DIY-Linux-routers.git
* cd *DIY-Linux-routers-repo-dir*
# Virtual DIY Linux routers!
This is a small excercise to configure Linux servers as (internet facing) routers.
It's ment as a virtual solution and as a comparison to the functionality to solutions as Vyatta and NSX Edge routers.
The whole thing is created in Vagrant, with SaltStack as provisioning language. It uses Virtualbox as a virtual platform.
Testing is only done on a Windows machine due to lack of other equipment. YMMV on other platforms, although it shouldn't be hard to get this running under Linux or some form of BSD.

But Why?!? Because the benefits of a DIY router is flexibility in the solution and freedom to create whatever solution suits your situation.
The downside is the complete lack of (commercial) support and the complete responsibility for any form of maintenance.

## Installation
What do you need to go wild with this project?
* Install Vagrant
* Install Virtualbox
* git clone https://code.ogdsoftware.nl/bas.dusee/vagrang-Linux-routers.git
* cd *vagrant-Linux-routers-repo-dir*
* Vagrant up
* Vagrant ssh Edge1 (of Edge2 of Introuter, of Darkrouter, of Darkweb01/02)
* Vagrant ssh Edge1 (or Edge2 or Introuter, or Darkrouter, or Darkweb01/02)

## Design van het Vagrant netwerkje
Hier een netwerktekening:
![Netwerktekening](./documentatie/netwerktekening.png)
Edge1 en Edge2 zijn twee redundante Edge routers en hangen aan het Internet (in dit geval is het Internet een Host-Only netwerk met de Virtualbox host). Het idee is dat deze Active/Passive of Active/Active werken en elkaars werk kunnen overnemen.
## Network design of the Vagrant Linux router thingy
For your amusement, a network diagram:
![Networkdesign](./documentation/networkdrawing.png)
Edge1 en Edge2 are two redundant Edge routers which are connected to the Internet (The "Internet" in this case is a Host-Only network connected to the Virtualbox host). The general idea is to configure these routers Active/Passive or Active/Active. They should be able to replace each other when one of them fail.

Daarachter ligt een "intern" subnet (noem het een DMZ oid) waaraan een enkele interne router hangt (Introuter). Deze interne router ontsluit een nog dieper gelegen subnetje wat in eerste instantie niet bekend is bij de beide Edge routers (routing protocol nodig dus..). Op dat diepere netwerkje zitten twee webservers (ik voel een load balancing aankomen...).
Right behind this router there's an "intern" subnet (call it some sort of DMZ, which is not the correct term) to which a single internal router is connected (the Introuter). This router discloses a much more internal subnet which should be anounced to the Edge routers via a routing protocol. There are two webservers connected to this internal subnet. That sounds like a job for a load balancer...

Normaal gaat de routing naar internet door alle routers heen naar buiten, maar dankzij Vagrant en Virtualbox heeft elke router een eigen Virtualbox NAT adapter. De NAT adapters hebben op elke box exact hetzelfde IP adres (10.0.2.15) en altijd de default route erheen geforceerd. Dit is lastig eruit te slopen. Ik heb dit netwerk maar "mgmt" genoemd om het voor een management subnet te laten doorgaan, dat is in het echt vaak ook zo. Alleen de default gateway door het management VLAN is nogal funky. Wel is het makkelijk met deployen, Introuter kan zo simpel pakketten installeren. In een real life scenario wil je dit anders hebben natuurlijk!
Virtualbox is a little weird considering networking, especially when you use Vagrant. It's very difficult to not use the "NAT" network connector on each router, because this is the interface Vagrant provisions over. So there is a funky default route problem, which points to the "NAT" interface by default. All routers have 10.0.2.15 as an IP on the "NAT" interface, and the default route allways points to 10.0.2.2. I'm still figuring out a good way to solve this.

## Ontwerp van de DIY box
De boxen zelf zijn op basis van Debian 9 (Ubuntu vertrouw ik niet 100%, die installeert nog wel eens meuk, en CentOS ben ik niet zo mee bekend). Ik gebruik de Bentobox ervan omdat daar de Virtualbox guest drivers al in zitten (nodig voor mounten host directory). In een prod environment is het handig zelf Debian te installeren en deployen vanaf de officiële distro repositories, uiteraard.
## Design of the DIY routers
The Vagrant routers are all made of "bento" boxes and I use the Debian 9 variety right now. It's really advisable to do a manual (or automated) install of Debian yourself in a real production environment. I do not really know what's in the Bento boxes exactly. The reason for choosing Bento, is the already installed guest drivers, which are needed for provisioning from Vagrant.

### Configuratie management boxen
Configuratie gebeurd via Salt vanuit Vagrant. Ik gebruik Salt omdat ik het ken. Dit kan net zo makkelijk met de Chef of Ansible plugin natuurlijk. Er gebeuren geen spannende dingen met Salt, alleen pakketjes installeren en config files parsen en plaatsen. Eenieder kan de files lezen en snappen wat er gebeurd en makkelijk dit nabouwen in je eigen favo config tool.
### Configuration of the routers
Vagrant configures the machines automatically, using it's builtin SaltStack provisioner. I choose Salt because I'm familiair to it. You can use "vagrant provision" to re-provision already created machines.
You can just as easily implement this using Ansible or Chef (both supported in Vagrant). There are no special tricks involved in the provisioning which is only accessible to Salt.

### software keuze
De boxen krijgen (een deel van) de onderstaande software voor de volgende functies:
* **BIRD** - voor de Routing protocollen. Ik gebruik OSPF. Quagga kon ook, maar BIRD is de industrie standaard tegenwoordig. BIRD heeft meer toeters en bellen, zoals multiple OSPF instances, wat Quagga niet kan.
* **iptables-persistent** - Voor firewalling en NAT doe ik gewoon iptables. Dit geeft de meeste flexibiliteit. Wel kan het wat complex overkomen en is het iets foutgevoeliger. Alternatieven kunnen zijn: firewalld of ufw. Beiden ben ik niet zo'n fan van, maar deze zijn prima te gebruiken in dit scenario.
* **OpenVPN** - Remote access SSL inbellen. site2site kan ook, maar dat doe ik liever met IPSEC.
* **StrongSwan** - site to site ipsec VPN oplossing. Intersteunt IKEv1 en IKEv2. Remote Access kan ook. Zelfs met Windows 10 native tools. Ga ik wel mee testen.
* **Failover** - Systeem om de Edges elkaar laten overnemen. Pacemaker gebruik ik daar nu voor, maar dit kan ook met Keelalived of kaal met Heartbeat (minder handig, maar kan).
### Choice of installed software
The routers are configured with (parts of) the following software:
* **BIRD** - for Routing protocols. I use OSPF mainly here. Quagga was also an option in this environment, but BIRD is the industry standard at the moment. BIRD has more bells and whistles, like multiple OSPF instances, which Quagga is unable to do.
* **iptables-persistent** - I use/choose plain iptables for firewalling and NAT. This gives me the most flexibility although it looks the most complex and is the most error prone due to typing errors. Considered alternatives were: firewalld or ufw. I dislike both, but they are very usefull in this scenario.
* **OpenVPN** - For remote access SSL VPN. site2site is also possible with OpenVPN, but IPSEC is more suited for this.
* **StrongSwan** - site to site ipsec VPN solution. Supports IKEv1 and IKEv2. Remote Access VPN is also possible, but cumbersome.
* **Failover** - This example uses keepalived to manage a virtual IP address with failover capabilities.
2 changes: 2 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Vagrant.configure("2") do |config|

edge1.vm.network "private_network", ip: "192.168.23.5/24", nic_type: "virtio"
edge1.vm.network "private_network", ip: "172.23.0.250/24", virtualbox__intnet: "internal-affairs", nic_type: "virtio"
edge1.vm.network "private_network", ip: "192.168.212.1/30", virtualbox__intnet: "conntrack", nic_type: "virtio"
edge1.vm.provider "virtualbox" do |vb|
vb.memory = "256"
vb.name = "edge1"
Expand All @@ -57,6 +58,7 @@ Vagrant.configure("2") do |config|

edge2.vm.network "private_network", ip: "192.168.23.6/24", nic_type: "virtio"
edge2.vm.network "private_network", ip: "172.23.0.251/24", virtualbox__intnet: "internal-affairs", nic_type: "virtio"
edge2.vm.network "private_network", ip: "192.168.212.2/30", virtualbox__intnet: "conntrack", nic_type: "virtio"
edge2.vm.provider "virtualbox" do |vb|
vb.memory = "256"
vb.name = "edge2"
Expand Down
File renamed without changes
File renamed without changes
6 changes: 4 additions & 2 deletions salt/roots/basis/init.sls
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pakkettenlijst:
packagelist:
pkg.installed:
- pkgs:
- tmux
Expand All @@ -20,8 +20,10 @@ pakkettenlijst:
- dc
- dnstracer
- iptraf
- elinks
- iptstate

geen_rpc_meuk:
no_rpc_bs:
service.dead:
- name: rpcbind
- enable: False
2 changes: 1 addition & 1 deletion salt/roots/failover/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ net.ipv4.ip_nonlocal_bind:
sysctl.present:
- value: 1

failover_pakketten:
failover_packages:
pkg.installed:
- pkgs:
- libipset3 # critical for keepalived, Y U no dependancy?!?
Expand Down
2 changes: 1 addition & 1 deletion salt/roots/firewall/edge.sls
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
firewallpakkettenlijst:
firewallpackagelist:
pkg.installed:
- pkgs:
- iptables-persistent
Expand Down
10 changes: 5 additions & 5 deletions salt/roots/firewall/intern.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def run():
config = {}

# Install packages, no magic here
config['firewallpakkettenlijst'] = {
config['firewallpackagelist'] = {
'pkg.installed': [
{'name': 'iptables-persistent'},
],
Expand All @@ -17,11 +17,11 @@ def run():
# get hostname for targeting firewall
hostname = __grains__['host']
if 'router' in hostname:
vuurmuur = __pillar__['router']['firewall']
fireports = __pillar__['router']['firewall']
elif 'web' in hostname:
vuurmuur = __pillar__['webserver']['firewall']
fireports = __pillar__['webserver']['firewall']
else:
vuurmuur = False
fireports = False

# get all the interfaces and strip off lo
int4 = __grains__['ip4_interfaces']
Expand Down Expand Up @@ -53,7 +53,7 @@ def run():
'mgmt': mgmt,
'intint': int4.keys(),
'appserver': appserver,
'vuurmuur': vuurmuur
'fireports': fireports
}
}
]
Expand Down
5 changes: 5 additions & 0 deletions salt/roots/firewall/rules.v4.edge.jinja
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{%- set mgmt = "enp0s3" -%}
{%- set intern = "enp0s9" %}
{%- set extern = "enp0s8" -%}
{%- set conntrack = "enp0s10" -%}
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
Expand All @@ -22,6 +23,7 @@ COMMIT
:mgmt - [0:0]
:mgmtTCP - [0:0]
:mgmtUDP - [0:0]
:conntracktbl - [0:0]
:internforward - [0:0]
:internTCPforward - [0:0]
:internUDPforward - [0:0]
Expand All @@ -32,6 +34,7 @@ COMMIT
-A INPUT -i {{ mgmt }} -j mgmt
-A INPUT -i {{ intern }} -j intern
-A INPUT -i {{ extern }} -j extern
-A INPUT -i {{ conntrack }} -j conntracktbl
-A INPUT -p tcp -j REJECT --reject-with tcp-reset
-A INPUT -p udp -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
Expand All @@ -53,6 +56,8 @@ COMMIT
-A mgmt -p udp -m conntrack --ctstate NEW -j mgmtUDP
-A mgmtTCP -p tcp -m tcp --dport 22 -j ACCEPT
-A mgmtUDP -p udp -m udp --dport 68 -j ACCEPT
-A conntracktbl -p udp -i $IFCONN -d 225.0.0.50/32 --dport 3780 -j ACCEPT
-A conntracktbl -p udp -i $IFCONN -s $IPCONN --dport 694 -j ACCEPT
-A internforward -p icmp -m icmp --icmp-type 8 -m conntrack --ctstate NEW -j ACCEPT
-A internforward -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -m conntrack --ctstate NEW -j internTCPforward
-A internforward -p udp -m conntrack --ctstate NEW -j internUDPforward
Expand Down
4 changes: 2 additions & 2 deletions salt/roots/firewall/rules.v4.intern.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ COMMIT
-A intern -p ospf -j ACCEPT
-A intern -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -m conntrack --ctstate NEW -j internTCP
-A intern -p udp -m conntrack --ctstate NEW -j internUDP
{%- for port in vuurmuur['tcp'] %}
{%- for port in fireports['tcp'] %}
-A internTCP -p tcp -m tcp --dport {{ port }} -j ACCEPT
{%- endfor -%}
{%- for port in vuurmuur['udp'] %}
{%- for port in fireports['udp'] %}
-A internUDP -p udp -m udp --dport {{ port }} -j ACCEPT
{% endfor -%}
-A mgmt -p icmp -m icmp --icmp-type 8 -m conntrack --ctstate NEW -j ACCEPT
Expand Down
2 changes: 1 addition & 1 deletion salt/roots/vpn/init.sls
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
vpnpakkettenlijst:
vpnpackagelist:
pkg.installed:
- pkgs:
- strongswan
Expand Down
Loading

0 comments on commit cb31089

Please sign in to comment.