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:

commit
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

top
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
exit
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
cli
configure exclusive

# Configure root user key / password
set system root-authentication load-key-file
[OR]
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
top
set system host-name "host01"

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

# Setup new user and assign login class
edit
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
[OR]
# Configure RADIUS
set system radius-server 10.11.12.254 source-address 10.11.12.1
edit system radius-server 10.11.12.254
set secret <pass-phrase>
set port 1845
# Ensure radius requests originate from the mgmt interface
routing-instance mgmt_junos
exit
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 1.2.3.254/24

### 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
commit

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
end

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 10.11.12.13 -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

Thursday, 23 May 2019

Cross compile packages for OpenWRT / LEDE

For this tutorial I'll be using Fedora 29 for the build host.

We'll install the necessary dependencies firstly:

sudo dnf install asciidoc binutils bzip2 flex git gawk intltool zlib gmake ncurses openssl-devel patchutils p5-extutils-makemaker unzip wget gettext libxslt zlib-devel boost-jam perl-XML-Parser libusb-devel dev86 sharutils java-1.7.0-openjdk-devel b43-fwcutter zip

The next step is to obtain the OpenWRT SDK which will allows us to cross-compile packages that we require on OpenWRT.

I'll be using a BT Home Hub 5A for this exercise - so I browse the releases:

https://downloads.openwrt.org/releases/17.01.4/targets/lantiq/xrx200/

Under the supplementary section you should find the SDK e.g.

lede-sdk-<version-number>-<vendor>-<model>_gcc-<version number>_musl-<version number>.Linux-<architecure>.tar.xz

We'll proceed by downloading and extracting it:

wget https://downloads.openwrt.org/releases/17.01.4/targets/lantiq/xrx200/lede-sdk-17.01.4-lantiq-xrx200_gcc-5.4.0_musl-1.1.16.Linux-x86_64.tar.xz

tar xvf lede-sdk-17.01.4-lantiq-xrx200_gcc-5.4.0_musl-1.1.16.Linux-x86_64.tar.xz && cd lede-sdk-17.01.4-lantiq-xrx200_gcc-5.4.0_musl-1.1.16.Linux-x86_64

The default feeds will be targeted at 17.01.4 and hence be missing fping - however the current master branch has fping available - so we'll add the following line to feeds.conf.default ensure it's indexed / available:

src-git fping https://github.com/openwrt/packages.git

Update the feeds (as defined in feeds.conf.default):

./scripts/feeds update -a

and grab fping with:

./scripts/feeds install fping

We'll generate our config file:

make menuconfig

Select 'Network' and ensure the fping package is marked with an 'M' and then save the changes to '.config'

Also make sure that cryptographic signing is disabled (otherwise the build process will fail): 'Global build settings' > Untick 'Cryptographically sign package lists' and hit Save.

We'll now attempt to compile fping:

make -j1 V=s

The binary is created in the following directory:

bin/packages/mips_24kc/fping/

Finally upload the package via SFTP/SCP to the router and install it with opkg:

opkg install fping_4.2-1_mips_24kc.ipk

Wednesday, 8 May 2019

Linux: Backup Options

There are countless ways to backup disks easily with Linux - however I'm going to demonstrate some of the more commonly used methods.

Forenote: Always ensure the discs are not in use / mounted while performing the below operations otherwise it is likely that new / changed files will be corrupted and will run into problems with the file system.

Backing up a disk with dd 

sudo dd if=/dev/xvda of=/mnt/usbdrive | sync

or better yet we can use a sane block size (dd uses 512 bytes by default):

sudo dd bs=16M if=/dev/xvda of=/mnt/usbdrive | sync

Backing up a disk with dd over ssh

Utilising SSH provides us with encryption - ideal for remote backups e.g. over public networks:

sudo ssh user@remote "dd if=/dev/xvda1 " | dd of=backup.gz

However it does introduce an overhead due to the encryption - so we can pipe it into gzip in order to speed things up:

sudo ssh user@remote "dd if=/dev/xvda1 | gzip -1 -" | dd of=backup.gz

Backing up a mounted system with rsync

If the system is currently mounted we can use rsync to perform a backup (ensuring we exclude certain directories such as /dev, /mnt etc):

sudo rsync -aAXv / --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /mnt

In the above command we employ 'archive' mode that ensures symbolic links, devices, permissions, ownerships, modification times, ACLs, and extended attributes are preserved.

and over rsync over SSH

sudo rsync -aAXve ssh user@remote:/ --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /mnt

There are of course many other ways to skin a cat e.g. using netcat (which is significantly faster than dd over SSH - however lacks encryption.) 

Sources

Thursday, 18 April 2019

Uploading ISO's to storage domains in oVirt

oVirt currently doesn't allow you to upload ISO's over its web interface - you'll need to use the cli to do this.

If you wish to upload an ISO to an ISO storage domain you should issue you should issue:

engine-iso-uploader --iso-domain <storage-domain-name> upload <path-to-iso>