Categories
Programming

Test if files exists

Searches in $directory for any files that begin with $today. If it find any files the script will exit.

[code language=”bash”]
#!/bin/bash

if [ $daily -eq "1" ] ; then
if ! find $directory -type f -name "$today*" -exec false {} + ; then
exit;
fi;
fi;
[/code]

Categories
Programming

Test if pingable

The code snippet belows try to ping $host. if ping fails (ping returns none zero value exitcode) the script exits.

[code language=”bash”]
#!/bin/bash
if [ $ping -eq "1" ] ; then
if ! ping -w 4 -c 1 $host > /dev/null 2>&1 ; then
exit
fi;
fi;
[/code]

Categories
Linux Network

Linux DHCP renew

howto renew your DHCP lease without restarting your network interface. First release your current lease and then request a new for interface eth0.

[code language=”bash”]
dhclient -r eth0
dhclient eth0
[/code]

Categories
Network Virtualization

OpenMediaVault / Debian network configuration for bonding/lacp and vlan

This is an example of an network configuration on my OpenMediaVault server. It takes two network interfaces (eth3 and rename3) and bonds them together using LACP. On top off this bond i have created three bridges. br1 witch is for untagged traffic and. br641 and 642 for vlan tagged traffic on vlan 641 and 642 respectively. br1/br641/br642 are all attached to the host and is configured for dhcp. they can also be attached to virtual machines.

Categories
Windows

Windows 10 and ViewCast Osprey 700e

This video card is not produced anymore and the last driver (Version 2.1.0.92) is from 2013. This card works fine with Windows 10 if you disable fast startup mode.

Categories
Network Windows

VNC with INTEL AMT

To allow tightVNC and UltraVNC connect to your AMT machine you need change redirection ports to all ports. you can to this from remote using Intel AMT SDK You will be promptet do add an rfb (vnc) password.

If you get a black/no screen then using TightVNC/UltraVNC you need to update your AMT Firmware on the motherboard.

Categories
Network pfSense

Full use of OpenDNS with pfSense

These steeps will show you how to use OpenDNS instead of your ISPs DNS in pfSense, and how to setup a free home account at OpenDNS to start filtering DNS request, and by that blocking unwanted traffic.

Categories
Linux Virtualization Windows

KVM With usb/pci passthrough

Creating a Virtual Machine for Windows 10

[code language=”bash”]
virt-install \
–name=Windows10-VM1 \
–ram=4096 \
–cpu=host \
–vcpus=2 \
–os-type=windows \
–os-variant=win7 \
–disk /srv/dev-disk-by-label-SSD/kvm/Windows10-VM1,size=200,sparse=true,bus=virtio \
–disk /zfs-pool-1/kvm/iso/Windows10.iso,device=cdrom,bus=ide \
–disk /zfs-pool-1/kvm/iso/virtio-win.iso,device=cdrom,bus=ide \
–network bridge=br0 \
–graphics vnc,listen=0.0.0.0
[/code]

Categories
Network

Testing multiple ports

Redirecting a range of ports

Usefull if you need to test a range of ports but dont have a server that listen to all the ports. this forward to the webserver. run
[code laungage=”bash”]firewall-cmd –zone=public –add-forward-port=port=6000-6500:proto=tcp:toport=80[/code]

reload the firewall then you have finished testing to remove the rule.
[code laungage=”bash”]firewall-cmd –reload[/code]

Test if port range is open

[code laungage=”bash”]nmap -d2 -p 6000-6500 samuel.dalesjo.nu > 6000-6500.txt[/code]

Categories
Storage

ZFS the beginning

How i created my first pool

Raidz2 has two redundant drives (aka raid6). on spare drive and autoreplace on so the spare drive is used automatic in case of drive failure.
[code language=”bash”]
zpool create zfs-pool-1 raidz2 /dev/disk/by-id/ata-TOSHIBA_HDWN180_67PQK0NNFP9E /dev/disk/by-id/ata-TOSHIBA_HDWN180_67PQK0NGFP9E /dev/disk/by-id/ata-TOSHIBA_HDWN180_67PSK0YAFP9E /dev/disk/by-id/ata-TOSHIBA_HDWN180_67PUK0KWFP9E /dev/disk/by-id/ata-TOSHIBA_HDWN180_67PUK0KUFP9E /dev/disk/by-id/ata-ST8000VN0022-2EL112_ZA16NRDD /dev/disk/by-id/ata-ST8000VN0022-2EL112_ZA16NR57 /dev/disk/by-id/ata-ST8000VN0022-2EL112_ZA16KL2F /dev/disk/by-id/ata-ST8000VN0022-2EL112_ZA16PGEQ /dev/disk/by-id/ata-ST8000VN0022-2EL112_ZA16PH49
zpool add zfs-pool-1 spare /dev/disk/by-id/ata-ST8000VN0022-2EL112_ZA15N257
zpool set autoreplace=on zfs-pool-1
[/code]