Tuesday, 10 September 2019

Locking down ISAKMP / IPSec (UDP 500 , 4500 and IP 50) on the ASA 5500 Series

By default when enabling ISAKMP / IPSec on an interface the ASA permits access to the service (UDP 500, 4500 and IPSec) to everyone. However in some circumstances where you can reliably predict the source of VPN initiaitors you should ideally lock down access. Unfortuantely this can't be performed via apply an ACL to the interface and instead needs to be performed via the control pane.

We'll firstly need to obtain a list of the IP's in tunnel groups and add them to an ACL e.g.:

access-list outside-control-plane extended permit udp host <REMOTE PEER #1> host <ASA-VPN-ENABLED-INTERFACE> eq 500
access-list outside-control-plane extended permit udp host <REMOTE PEER #2> host <ASA-VPN-ENABLED-INTERFACE> eq 500
access-list outside-control-plane extended deny udp any any eq 500

access-list outside-control-plane extended permit udp host <REMOTE PEER #1> host <ASA-VPN-ENABLED-INTERFACE> eq 4500
access-list outside-control-plane extended permit udp host <REMOTE PEER #2> host <ASA-VPN-ENABLED-INTERFACE> eq 4500
access-list outside-control-plane extended deny udp any any eq 4500

access-list outside-control-plane extended permit ipsec host <REMOTE PEER #1> host <ASA-VPN-ENABLED-INTERFACE>
access-list outside-control-plane extended permit ipsec host <REMOTE PEER #2> host <ASA-VPN-ENABLED-INTERFACE>
access-list outside-control-plane extended deny ipsec any any

access-group outside-control-plane in interface outside-pri control-plane

Note: The above examples presume you do NOT have any IPSec VPN servers behind the firewall.

We can also perform the same for SSL VPNs:

access-list outside-control-plane extended permit tcp host <REMOTE PEER #1> host <ASA-VPN-ENABLED-INTERFACE> eq 443
access-list outside-control-plane extended permit tcp host <REMOTE PEER #2> host <ASA-VPN-ENABLED-INTERFACE> eq 443
access-list outside-control-plane extended deny tcp any <ASA-VPN-ENABLED-INTERFACE> eq 443

Thursday, 8 August 2019

Setting up bonding with LACP using the ip command in Linux

This can be accomplished quite quickly with the IP command if you only need it temporarily:

ip link add bond0 type bond
ip link set bond0 down
ip link set bond0 type bond mode 802.3ad
ip link set enp1s0 down
ip link set enp1s0 master bond0
ip link set enp2s0 down
ip link set enp2s0 master bond0
ip link set bond0 up

and to remove the bonding we can issue:

ip link del bond0
ip link set enp1s0 up
ip link set enp2s0 up

Quickstart: Installing Arch Linux 2019.X

Firstly download the latest iso image from one of the mirrors below:

wget https://www.mirrorservice.org/sites/ftp.archlinux.org/iso/2019.08.01/archlinux-xxxx.xx.xx-x86_64.iso
and then write it to your preferred media:
dd bs=8M if=archlinux-xxxx.xx.xx-x86_64.iso of=/dev/sdX | sync
Upon booting the image select the default selection to boot Arch.

This will get you into the system under the root user.

The setup portion is a Gentoo style approach of efffectively 'assembling' the system yourself.

From here we'll firstly partition the disks:
sdX               8:0    0 1000G  0 disk 

In this example we'll create three partitions - one for the root fs, another for our home fs and finally one for swap.
parted -a optimal /dev/sdXhyu
mktable gpt
mkpart ESP boot fat32 0% 500MB
mkpart root ext4 500MB 250000MB
mkpart home ext4 250GB 750GB
mkpart swap ext4 750GB 800GB
set 1 boot on
Create the filesystems with:
mkfs.msdos /dev/sdX1
mkfs.ext4 /dev/sdX2
mkfs.ext4 /dev/sdX3
mkfs.ext4 /dev/sdX4
mkswap /dev/sdX4
swapon /dev/sdX4
Proceed by mounting the file systems:
mount -t auto /dev/sdX2 /mnt
mkdir -P /mnt/boot/EFI && mount -t auto /dev/SdX1 /mnt/boot/EFI
mkdir /mnt/home && mount -t auto /dev/SdX3 /mnt/home
We'll need the network setup at this point so we can access the arch repo's:
and then pull down all the nessasery compontents for the root fs:
pacstrap /mnt base base-devel
Once complete we'll need to generate the fstab for the new system:
genfstab -U /mnt >> /mnt/etc/fstab
and then change our root password by chrooting into the new system along with the hostname:
arch-chroot /mnt
hostname arch-box
We'll also configure regional and time settings with:
ln -sf /usr/share/zoneinfo/<region>/<city> /etc/localtime
hwclock --systohc
printf "LANG=en_GB.UTF-8" > /etc/locale.conf
export LANG=en_GB.UTF-8
I'm going to use KDE Plasma for the desktop environment:
pacman -S xorg xorg-server xorg-xinit plasma-meta sddm
Finally we will configure grub:
pacman -S grub efibootmgr dosfstools os-prober mtools
grub-install --target=x86_64-efi --efi-directory=/boot/EFI --bootloader-id=grub_uefi --recheck
grub-mkconfig -o /boot/grub/grub.cfg
Exit the jail:
and restart:
shutdown -r now
Once booted into the new OS we'll setup the network configuration - for this example I'll be setting up DHCP.

With Arch we have a few options for network configuration - either netctl or networkd (a newer component.)
vi /etc/netctl/enp2s0
Description=LAN interface
Ensure the interface will come up on boot by issuing:
netctl enable enp2s0
Enable and start the DHCP service with:
systemctl enable dhcpcd
systemctl start dhcpcd
and then attempt to start the interface with:
netctl start enp2s0

Friday, 12 July 2019

Using Juniper SRX devices as routers

The SRX series are part of Junipers security line of products and provide firewall among a host of other security features such as IDS and IPS.

However you can effectively use the SRX range as a traditional router by changing the forwarding mode from flow based (stateful inspected) to packet based (stateless per packet inspection.)

You can verify the forwarding mode by issuing:

show security flow status

We should firstly ensure we remove any existing security configuration from the device with:

delete security

and then ensure the forwarding mode is set to 'packet based':

set security forwarding-options family mpls mode packet-based

commit it and then reboot:

run request system reboot

Upon restart check the forwarding mode again with:

show security flow status

Thursday, 4 July 2019

Configuring an Etherchannel (with LACP) between JunOS and Cisco IOS

Juniper JunOS

Firstly create the aggregated interface:

edit chassis
set aggregated-devices ethernet device-count 2

edit interfaces
set ae0 aggregated-ether-options

and define the LACP interval period (i.e. the rate at which the device will send / receive LACP protocol messages):

set aex aggregated-ether-options lacp periodic fast

By default the 'lacp periodic fast' sets the transmission rate to 1 second.

Note: It's important that the rate is matched on the other end as well.

We'll now associate our interfaces with the aggregated link we've just configured:

edit interfaces
edit ge-0/0/1
set ether-options 802.3ad ae0
edit ge-0/0/2
set ether-options 802.3ad ae0

Cisco IOS

conf t
int range gi1/0/1-2
channel-protocol lacp
channel-group 1 mode active
lacp rate fast
no shut

int po1
description etherchannel

Tuesday, 2 July 2019

Base Junos Configuration

The following template will get the fundamental features setup in Junos and act as a base for building more advanced configurations:

# Enter configuration mode
configure exclusive

# Configure root user key / password
set system root-authentication load-key-file
set system root-authentication plain-text-password

# Enable remote management
edit system services
active ssh
ativate web-management https
set web-management https port 443
set web-management https system-generated-certificate
set web-management https interface fxp0.0

# Disable insecure services
deactivate telnet
decativate web-management http

# Setup hostname
set system host-name "host01"

# Setup time / date / ntp
set system time-zone Europe/London
set date ntp 1.uk.pool.ntp.org
set cli idle-timeout 10

# Setup new user and assign login class
edit system login
edit user jbloggs
set authentication plain-text-password
set full-name "Joe Bloggs"
set class operator | read-only | super-user

# Create custom login class
set system login class test-class permissions [interface interface-control]
set system login class test-class idle-timeout 10
# Configure RADIUS
set system radius-server source-address
edit system radius-server
set secret <pass-phrase>
set port 1845
# Ensure radius requests originate from the mgmt interface
routing-instance mgmt_junos
set system authentication-order [radius password]
# Assign a default class for remote users
set system login user remote class super-user

### Setup Layer 3 Interface
# Change physical properties
edit interfaces ge-0/0/1
set speed 10m
set link-mode full-duplex

### Create VLAN
set vlans testvlan vlan-id 123
set vlans testvlan2 vlan-id 456

# Change logical properties
edit interfaces ge-0/0/1 unit 0
set vlan-id 50
edit family inet
set address

### Setup Access Port
# Change logical properties
edit interfaces ge-0/0/2 unit 0
set family ethernet-switching interface-mode access
set family ethernet-switching vlan members 123

### Setup Trunk Port
edit interfaces ge-0/0/3 unit 0
set family ethernet-switching port-mode trunk vlan members [testvlan testvlan2]

### Syslog Forwarding
* This is performed via the local syslog server rather than the Juniper CLI (messages found in /var/log/messages)
* To edit the configuration from the CLI use 'edit system syslog'.

### Commit changes

Wednesday, 29 May 2019

Configuring Auto QoS on Cisco Switches

Auto QoS is a great feature included with the majority of switches running at least the LAN Base feature set. It will likely require some further tweaking after it's setup however it's a great base for applying QoS.

Cisco provides support for it's own telephony devices (surprise, surprise!) through CDP broadcasts. However in my case I am working with a different vendor and since not all switches will provide classification of packets I'm relying on the tagging being performed by the downstream devices.

It's very simple to setup - simply apply the following to the switch ports in scope (i.e. the ones connected to the telephony devices):

conf t
int range gi1/0/1-10
auto qos trust dscp

This will instruct the switch ports in scope to trust DSCP markings applied by the downstream devices (as I'm sure you're aware by default DSCP marking are typically stripped.)

The 'auto qos trust dscp' also enables qos globally for us and also applies a few other directives on the interface - so in reality a lot of the setup is performed for you - however in reality it's still crucial that you understand what each directives means!

do show run int gi1/0/1

interface GigabitEthernet1/0/1
 switchport access vlan 2000
 switchport mode access
 speed auto
 srr-queue bandwidth share 1 30 35 5
 priority-queue out
 mls qos trust dscp
 auto qos trust dscp
 spanning-tree portfast
 spanning-tree bpduguard enable

To verify QoS is turned on globally we can review:

show mls qos

and to review interface specific QoS information:

show mls qos interface gi1/0/1

We can also test QoS is successfully prioritising packets with iperf (tagging the traffic with a non zero DSCP value) e.g.:

iperf -c -i 1 -S 0xB8 -t 0

'0xB8' is the hexadecimal equivalent of TOS's 184 - which equates to DSCP's 'ef' / 46. According to the man page (at least in mine) the value must be in hexadecimal TOS form. There is an list of all of them available here.

We can then review the QoS counters for the interface with:

show mls qos interface gi1/0/1 stat