# Project 1 - Network Redundancy



## Base Configurations:

### Xubuntu-WAN and LAN

Set Hostname:

<figure><img src="https://2309351619-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FONkWEMWluEABqm3rOYht%2Fuploads%2F5isNAUZ7EK0kdx68u7PX%2Fimage.png?alt=media&#x26;token=d3977c47-5a3a-4599-8817-c23782128421" alt=""><figcaption></figcaption></figure>

Change champuser Passwd and add paul user:

<figure><img src="https://2309351619-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FONkWEMWluEABqm3rOYht%2Fuploads%2FnqLlbh7xIm7TpiwLfn28%2Fimage.png?alt=media&#x26;token=c930b2e4-a171-4ee3-bc65-0d0159dcda1a" alt=""><figcaption></figcaption></figure>

Make paul user sudoer:

<figure><img src="https://2309351619-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FONkWEMWluEABqm3rOYht%2Fuploads%2F0qomCDLaPIvsfGQGrRLu%2Fimage.png?alt=media&#x26;token=2c3d0913-dc8c-4998-8b5c-d28bc9456ba2" alt=""><figcaption></figcaption></figure>

Setup Networking WAN:

<figure><img src="https://2309351619-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FONkWEMWluEABqm3rOYht%2Fuploads%2Fiq03ucToC1Hz5m9gvUY0%2Fimage.png?alt=media&#x26;token=f16664d2-7cd1-4922-b227-3fe1fa2840f9" alt=""><figcaption></figcaption></figure>

Setup Networking LAN:

<figure><img src="https://2309351619-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FONkWEMWluEABqm3rOYht%2Fuploads%2FgVGfIfaL1TCbP4CgUTKd%2Fimage.png?alt=media&#x26;token=0b26c0e0-7880-4456-9cb3-f3f3c714683c" alt=""><figcaption><p>LAN setup</p></figcaption></figure>

### Web01 Setup:

<figure><img src="https://2309351619-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FONkWEMWluEABqm3rOYht%2Fuploads%2FG2CnclAm8iHVq2zUl9LA%2Fimage.png?alt=media&#x26;token=a46dc12a-52e5-48cb-bef6-d830dcfa1bce" alt=""><figcaption><p>Network Config</p></figcaption></figure>

<figure><img src="https://2309351619-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FONkWEMWluEABqm3rOYht%2Fuploads%2FYpxRWsezkNUxaciwkPTa%2Fimage.png?alt=media&#x26;token=a14867c5-d847-4561-9d23-f0a811804878" alt=""><figcaption><p>Set Hostname</p></figcaption></figure>

Add Paul user:

```bash
adduser paul
passwd paul
usermod -aG wheel paul
```

Allow ssh and http

<figure><img src="https://2309351619-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FONkWEMWluEABqm3rOYht%2Fuploads%2F0AgYBfLC1TgJKf8ZRB4h%2Fimage.png?alt=media&#x26;token=36042329-fe5b-49ac-894c-067d4ae10423" alt=""><figcaption></figcaption></figure>

### Vyos1 and 2

Set Hostnames:

```bash
set system host-name <HOSTNAME>
```

Change vyos user password:

```bash
set system login user vyos authentication plaintext-password
```

Make a new paul user:

```bash
set system login user <name> full-name “<string>”
```

```bash
set system login user <name> authentication plaintext-password <password>
```

Set Interfaces:

```bash
set interfaces ethernet eth0 description WAN
set interfaces ethernet eth1 description LAN
set interfaces ethernet eth2 description OPT
```

Vyos 1 Interfaces Addresses:

```bash
set interfaces ethernet eth0 address 10.0.17.16/24
set interfaces ethernet eth1 address 10.0.5.2/24
set interfaces ethernet eth2 address 10.0.6.2/24
set protocols static route 0.0.0.0/0 next-hop 10.0.17.2
set system name-server 10.0.17.2
```

Vyos 2 Interfaces Addresses:

```bash
set interfaces ethernet eth0 address 10.0.17.76/24
set interfaces ethernet eth1 address 10.0.5.3/24
set interfaces ethernet eth2 address 10.0.6.3/24
set protocols static route 0.0.0.0/0 next-hop 10.0.17.2
set system name-server 10.0.17.2
```

## Setup DNS

LAN to WAN:

```bash
set service dns forwarding allow-from 10.0.5.0/24
set service dns forwarding listen-address 10.0.5.1
set service dns forwarding system
```

## Setup NAT

LAN to WAN:

```bash
set nat source rule 10 description 'NAT FROM LAN to WAN'
set nat source rule 10 outband-interface eth0
set nat source rule 10 source address 10.0.5.0/24
set nat source rule 10 translation address masquerade
```

## Setup VRRP

WAN Config:

```bash
set high-availability vrrp group wangroup6 vrid 156
set high-availability vrrp group wangroup6 interface eth0
set high-availability vrrp group wangroup6 address 10.0.17.106/24
```

```bash
# For vyos01
set high-availability vrrp group wangroup6 priority 200
# For vyos02
set high-availability vrrp group wangroup6 priority 100
```

LAN Config:

```bash
set high-availability vrrp group langroup0 vrid 10
set high-availability vrrp group langroup0 interface eth1
set high-availability vrrp group langroup0 address 10.0.5.1/24
```

```bash
# For vyos01
set high-availability vrrp group langroup0 priority 200
# For vyos02
set high-availability vrrp group langroup0 priority 100
```

OPT Config:

```bash
set high-availability vrrp group optgroup0 vrid 20
set high-availability vrrp group optgroup0 interface eth2
set high-availability vrrp group optgroup0 address 10.0.6.1/24
```

```bash
# For vyos01
set high-availability vrrp group optgroup0 priority 200
# For vyos02
set high-availability vrrp group optgroup0 priority 100
```

## Setup Port Forwarding

Below is done on both vyos boxes!

Web Server on port 80 (web01)

```bash
set nat destination rule 20 destination address 10.0.17.106
set nat destination rule 20 destination port 80
set nat destination rule 20 inbound-interface eth0
set nat destination rule 20 protocol tcp
set nat destination rule 20 translation address 10.0.5.100
set nat destination rule 20 translation port 80
set nat destination rule 20 description HTTP->WEB01
```

SSH on port 22 (web01)

```bash
set nat destination rule 30 destination address 10.0.17.106
set nat destination rule 30 destination port 22
set nat destination rule 30 inbound-interface eth0
set nat destination rule 30 protocol tcp
set nat destination rule 30 translation address 10.0.5.100
set nat destination rule 30 translation port 22
set nat destination rule 30 description SSH->WEB01
```

## Adding 2fa to SSH

Follow this guide and stop at the end of step 2 [https://www.digitalocean.com/community/tutorials/how-to-set-up-multi-factor-authentication-for-ssh-on-centos-7](https://www.digitalocean.com/community/tutorials/how-to-set-up-multi-factor-authentication-for-ssh-on-centos-7)\


The ssh prompt will now look like:

<figure><img src="https://2309351619-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FONkWEMWluEABqm3rOYht%2Fuploads%2F6i3HW6tq3y4nKwElEX9E%2Fimage.png?alt=media&#x26;token=3eb03d8a-3335-4395-b9fd-59e9c0f0e4eb" alt=""><figcaption></figcaption></figure>

### VYOS01 Config

```bash
set high-availability vrrp group langroup0 address 10.0.5.1/24
set high-availability vrrp group langroup0 interface 'eth1'
set high-availability vrrp group langroup0 priority '200'
set high-availability vrrp group langroup0 vrid '10'
set high-availability vrrp group optgroup0 address 10.0.6.1/24
set high-availability vrrp group optgroup0 interface 'eth2'
set high-availability vrrp group optgroup0 priority '200'
set high-availability vrrp group optgroup0 vrid '20'
set high-availability vrrp group wangroup6 address 10.0.17.106/24
set high-availability vrrp group wangroup6 interface 'eth0'
set high-availability vrrp group wangroup6 priority '200'
set high-availability vrrp group wangroup6 vrid '156'
set interfaces ethernet eth0 address '10.0.17.16/24'
set interfaces ethernet eth0 description 'WAN'
set interfaces ethernet eth1 address '10.0.5.2/24'
set interfaces ethernet eth1 description 'LAN'
set interfaces ethernet eth2 address '10.0.6.2/24'
set interfaces ethernet eth2 description 'OPT'
set nat destination rule 20 description 'HTTP->WEB01'
set nat destination rule 20 destination address '10.0.17.106'
set nat destination rule 20 destination port '80'
set nat destination rule 20 inbound-interface 'eth0'
set nat destination rule 20 protocol 'tcp'
set nat destination rule 20 translation address '10.0.5.100'
set nat destination rule 20 translation port '80'
set nat destination rule 30 description 'SSH->WEB01'
set nat destination rule 30 destination address '10.0.17.106'
set nat destination rule 30 destination port '22'
set nat destination rule 30 inbound-interface 'eth0'
set nat destination rule 30 protocol 'tcp'
set nat destination rule 30 translation address '10.0.5.100'
set nat destination rule 30 translation port '22'
set nat source rule 10 description 'NAT FROM LAN to WAN'
set nat source rule 10 outbound-interface 'eth0'
set nat source rule 10 source address '10.0.5.0/24'
set nat source rule 10 translation address 'masquerade'
set protocols static route 0.0.0.0/0 next-hop 10.0.17.2
set service dns forwarding allow-from '10.0.5.0/24'
set service dns forwarding listen-address '10.0.5.1'
set service dns forwarding system
set service ssh listen-address '0.0.0.0'
set system host-name 'vyos1-paul'
set system name-server '10.0.17.2'
```

### VYOS02 Config

```bash
set high-availability vrrp group langroup0 address 10.0.5.1/24
set high-availability vrrp group langroup0 interface 'eth1'
set high-availability vrrp group langroup0 priority '100'
set high-availability vrrp group langroup0 vrid '10'
set high-availability vrrp group optgroup0 address 10.0.6.1/24
set high-availability vrrp group optgroup0 interface 'eth2'
set high-availability vrrp group optgroup0 priority '100'
set high-availability vrrp group optgroup0 vrid '20'
set high-availability vrrp group wangroup6 address 10.0.17.106/24
set high-availability vrrp group wangroup6 interface 'eth0'
set high-availability vrrp group wangroup6 priority '100'
set high-availability vrrp group wangroup6 vrid '156'
set interfaces ethernet eth0 address '10.0.17.76/24'
set interfaces ethernet eth0 description 'WAN'
set interfaces ethernet eth1 address '10.0.5.3/24'
set interfaces ethernet eth1 description 'LAN'
set interfaces ethernet eth2 address '10.0.6.3/24'
set interfaces ethernet eth2 description 'OPT'
set nat destination rule 20 description 'HTTP->WEB01'
set nat destination rule 20 destination address '10.0.17.106'
set nat destination rule 20 destination port '80'
set nat destination rule 20 inbound-interface 'eth0'
set nat destination rule 20 protocol 'tcp'
set nat destination rule 20 translation address '10.0.5.100'
set nat destination rule 20 translation port '80'
set nat destination rule 30 description 'SSH->WEB01'
set nat destination rule 30 destination address '10.0.17.106'
set nat destination rule 30 destination port '22'
set nat destination rule 30 inbound-interface 'eth0'
set nat destination rule 30 protocol 'tcp'
set nat destination rule 30 translation address '10.0.5.100'
set nat destination rule 30 translation port '22'
set nat source rule 10 description 'NAT FROM LAN to WAN'
set nat source rule 10 outbound-interface 'eth0'
set nat source rule 10 source address '10.0.5.0/24'
set nat source rule 10 translation address 'masquerade'
set protocols static route 0.0.0.0/0 next-hop 10.0.17.2
set service dns forwarding allow-from '10.0.5.0/24'
set service dns forwarding listen-address '10.0.5.1'
set service dns forwarding system
set service ssh listen-address '0.0.0.0'
set system host-name 'vyos2-paul'
set system name-server '10.0.17.2'
```
