HowTo: Connect to an APC device with an unknown IP address

Have you ever been handed a device that has previously been configured by someone else and the IP details have disappeared?

We recently came across such a situation and thought we would share the trick we used to gain access to the device, which in turn allowed us to setup a new IP address.

This configuration was carried out on an APC AP7921, we wanted to assign IP 192.168.0.1

Firsty, find out the mac address of the unit, this should be on the back, our example 00 c0 b7 36 5c 62

Connect directly to the device using an Ethernet cable (cross over if required)

Having now found the mac address, we need to tell the arp table what the IP to MAC association should be

Windows command
arp -s 192.168.0.1 00-c0-b7-36-5c-62

Linux command
arp -s 192.168.0.1 00:c0:b7:36:5c:62

Now use ping with a packet size of 113 bytes which will assign the IP set in the ARP command

Windows command
ping 192.168.0.1 -l 113

Linux command
ping 192.168.0.1 -s 113

Now you should be able to connect using telnet or http and set the new IP address.  If you don’t know the password then you will need to use the reset button which usually requires a pin or paper click.

HowTo: Mounting Partitions within a XEN domU disk Image

If you have been using virtualisation technologies such as XEN, you would of come across the usage of disk images to store our operating system and data on.  To create one of these we run:

dd if=/dev/zero of=mydisk.img bs=1024k count=0 seek=5000

This would have created for me an image which is approximately 5GB in size. And then I format it to an ext3 file-system with:

This command will of create a new disk image, 5GB in size called mydisk.img.  This is where Debian will be installed but firstly we need to give the new disk a file sytem type, so we run:

mkfs.ext4 mydisk.img

The problems people may face is when the disk image isn’t formatted by dom0, but instead are formatted by an installer and creates more that one partition inside the image.

usually we can mount the newly formatted disk like this:

mount -o loop mydisk.img /mnt/disk1

But since the image which gets created during the installation process of the VM, has multiple partittions, a simple mount won’t work. This is what happens when we try to mount an image which has multiple partitions:

Since the installer creates multiple partitions inside the image, the normal easy mounting within dom0 will not work:

mount -o loop mydisk.img /mnt/disk1: you must specify the filesystem type

We can examine the file further by executing:

fdisk -lu hda

Which outputs:

You must set cylinders.
You can do this from the extra functions menu.

Disk hda: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes

Device Boot      Start         End      Blocks   Id  System
  centos.img   *     1060290    17848214     8393962+  83  Linux
Partition 1 has different physical/logical endings:
     phys=(1023, 254, 63) logical=(1110, 254, 63)
  hda2        17848215    20964824     1558305   83  Linux
Partition 2 has different physical/logical beginnings (non-Linux?):
     phys=(1023, 254, 63) logical=(1111, 0, 1)
Partition 2 has different physical/logical endings:
     phys=(1023, 254, 63) logical=(1304, 254, 63)

The ‘u’ flag inside fdisk tells us the partition table sizes in sectors rather than cylinders.  From here we will need this information so we can calculate the correct offset.

Calculate the Offset in “Bytes”

In order to mount the two partitions from the image, we need to know the starting Byte from where each partition starts. To calculate this offset, we mulitply the (start_sector * sector_byte_size). So for the Partition 1 we have (1060290 * 512) = 542868480 and for Partition 2 we have (17848215 * 512) = 9138286080.

Now we can use those “Start Byte” values to mount those partitions in two seperate locations:

mount -o loop,offset=542868480 mydisk.img /mnt/partition1
mount -o loop,offset=9138286080 mydisk.img /mnt/partition2

HowTo: Speed Up Linux Software Raid Building And Re-syncing

Sometimes when assembling a raid array, you may find that it is going to take hours, even worse, days to complete.  Luckily there are ways to increase the assemble time with some useful commands which should decrease the time considerably.

To increase the rebuild speed, enter:

echo value > /proc/sys/dev/raid/speed_limit_min

OR

sysctl -w dev.raid.speed_limit_min=value

In this example, set it to 60000 K/Sec, enter:

echo 60000 > /proc/sys/dev/raid/speed_limit_min

OR

sysctl -w dev.raid.speed_limit_min=60000

If you want to override the default settings you could add these two lines to /etc/sysctl.conf:

dev.raid.speed_limit_min = 60000
dev.raid.speed_limit_max = 200000

Bitmap Option

Bitmaps optimize rebuild time after a crash, or after removing and re-adding a device.

Turn it on by typing the following command:

mdadm –grow –bitmap=internal /dev/md0

Once array rebuild or fully synced, disable bitmaps:

mdadm –grow –bitmap=none /dev/md0

The net result

The rebuild rate jumps from 4k to 61k:

cat /proc/mdstat

Sample outputs:

Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]
md5 : active raid1 sde2[2](S) sdd2[3](S) sdc2[4](S) sdb2[1] sda2[0]
      530048 blocks [2/2] [UU]
md0 : active raid6 sde3[4] sdd3[3] sdc3[2] sdb3[1] sda3[0]
      5855836800 blocks level 6, 64k chunk, algorithm 2 [5/5] [UUUUU]
      [============>........]  resync = 61.7% (1205475036/1951945600) finish=242.9min speed=61204K/sec

HowTo: resolve the ‘/bin/rm: Argument list too long’ error

You may of come across this error like us when running the command rm -rf *, fortunately there is a workaround that should help:-

find . -name ‘test-*’ | xargs rm

In the above example the command will forcefully delete all of the files in the current directory that begin with test-. You can replace the parameter test-* with anything you like. You can also use * if you want to simply remove all the files

find . -name ‘*’ | xargs rm

Hopefully by running these commands will help you remove the files you want without getting stuck with the error.

HowTo: Install XEN Dom0 on Debian Jessie from source

HowTo: Install XEN Dom0 on Debian Jessie from source

xen logo
This article assumes you have a clean install of Debian and have root level access to the server. Note this was performed on a minimal install with no desktop.

Prereqs

To be able to perform a successful kernel build, you will need to install the following packages:

apt-get install bc bcc bin86 gawk bridge-utils iproute libcurl3 libcurl4-openssl-dev bzip2 module-init-tools transfig texinfo texlive-latex-base gcc-multilib texlive-fonts-extra texlive-fonts-recommended pciutils-dev mercurial libncurses5-dev patch libvncserver-dev libsdl-dev gettext libaio1 libaio-dev libssl-dev iasl libbz2-dev git-core uuid-dev python python-dev python-twisted build-essential make gcc libc6-dev zlib1g-dev texlive-latex-recommended e2fslibs-dev libyajl-dev libpixman-1-dev

XEN Compile and install

Now lets get the XEN tarball and make XEN

cd /usr/src

wget http://bits.xensource.com/oss-xen/release/4.7.0/xen-4.7.0.tar.gz

tar xvf xen-4.7.0.tar.gz

cd xen-4.7.0

./configure –enable-githttp –libdir=/usr/lib

make -j 5 xen

make -j 5 tools

make -j 5 stubdom

cd dist/install

cp -R * /

vi /etc/default/xendomains and comment out #XENDOMAINS_SAVE=/var/lib/xen/save

These tweeks should make XEN start at system startup and also create the bridge we need for the DomUs. Please note that rc3.d could be rc2.d depending on your runlevel, check with the command runlevel at the prompt.

ln -s /etc/init.d/xendomains /etc/rc0.d/S10xendomains

ln -s /etc/init.d/xendomains /etc/rc6.d/S10xendomains

ln -s /etc/init.d/xencommons /etc/rc3.d/S98xencommons

ln -s /etc/init.d/xendomains /etc/rc3.d/S98xendomains

ln -s /root/xendom0caps /etc/rc3.d/S98xendom0caps

ln -s /root/iptables-enable /etc/rc3.d/S99iptables-enable (not required)

vi /root/xendom0caps (add xl sched-credit -d Domain-0 -w 512)

chmod +x /root/xendom0caps

vi /etc/rc.local (add /usr/bin/setterm -powersave off -blank 0

vi /etc/xen/xend-config.sxp

find line (network-script network-bridge) and comment out

#network-script network-bridge

vi /etc/xen/xl.conf (disable autoballon)

autoballon=0

Interfaces

As newer versions of XEN can use the system bridge rather than its own script we need to edit the network configuration to invoke our new bridge. Firstly create our new bridge interface. Replace the IP values with your settings.

vi /etc/network/interfaces

auto xenbr0
iface xenbr0 inet static
bridge_ports eth0
address 172.20.45.1
netmask 255.255.0.0
network 172.20.0.0
broadcast 172.20.255.255
gateway 172.20.0.1

Once done reboot to ensure the config applies successfully.

Kernel Compile

Now XEN is complete we need to get our kernel for Dom0. Replace the kernel number with the version you want to use.

cd /usr/src

(Please note the kernel version maybe significantly newer than detailed here)

wget ftp://ftp.kernel.org/pub/linux/kernel/v4.x/linux-4.2.tar.gz

tar xvf linux-4.2.0.tar.gz

cd linux-4.2.0

make menuconfig

Go into Processor type and features

pic1

Statically enable all XEN features

pic21

Go back to the main menu and enter Device Drivers menu, then enter block devices menu

pic3

Statically enable the 2 XEN options

pic4

Go back to the Device Drivers menu and go down to XEN driver support

pic5

Statically enable all features

pic7

Go back to Device Drivers, go into Network device support and statically enable the 2 XEN options at the bottom

pic8

Exit out and save.

Note to make sure all options are selected run

cat /usr/src/linux-4.2.0/.config | grep XEN

You should see the same as

CONFIG_XEN=y
CONFIG_XEN_DOM0=y
CONFIG_XEN_PRIVILEGED_GUEST=y
CONFIG_XEN_PVHVM=y
CONFIG_XEN_MAX_DOMAIN_MEMORY=500
CONFIG_XEN_SAVE_RESTORE=y
CONFIG_XEN_DEBUG_FS=y
CONFIG_PCI_XEN=y
CONFIG_XEN_PCIDEV_FRONTEND=y
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_BLKDEV_BACKEND=y
CONFIG_NETXEN_NIC=m
CONFIG_XEN_NETDEV_FRONTEND=y
CONFIG_XEN_NETDEV_BACKEND=y
CONFIG_INPUT_XEN_KBDDEV_FRONTEND=y
CONFIG_HVC_XEN=y
CONFIG_HVC_XEN_FRONTEND=y
# CONFIG_XEN_WDT is not set
CONFIG_XEN_FBDEV_FRONTEND=y
CONFIG_XEN_BALLOON=y
CONFIG_XEN_BALLOON_MEMORY_HOTPLUG=y
CONFIG_XEN_SCRUB_PAGES=y
CONFIG_XEN_DEV_EVTCHN=y
CONFIG_XEN_BACKEND=y
CONFIG_XENFS=y
CONFIG_XEN_COMPAT_XENFS=y
CONFIG_XEN_SYS_HYPERVISOR=y
CONFIG_XEN_XENBUS_FRONTEND=y
CONFIG_XEN_GNTDEV=y
CONFIG_XEN_GRANT_DEV_ALLOC=y
CONFIG_SWIOTLB_XEN=y
CONFIG_XEN_PCIDEV_BACKEND=y
CONFIG_XEN_PRIVCMD=y
CONFIG_XEN_ACPI_PROCESSOR=y

If it looks good then continue otherwise please correct before hand.

make -j 5 bzImage

make -j 5 modules

make -j 5 INSTALL_MOD_STRIP=1 modules_install

cp -a arch/x86/boot/bzImage /boot/vmlinuz-4.2.0

cp -a System.map /boot/System.map-4.2.0

cp -a .config /boot/config-4.2.0

depmod –a

mkinitramfs -o /boot/initrd.img-4.2.0 4.2.0

Modify GRUB2 to boot in XEN mode

cd /etc/grub.d

mv 10_linux 50_linux

vi /etc/default/grub

add these lines under GRUB_CMDLINE_Linux””

GRUB_CMDLINE_XEN_DEFAULT=dom0_mem=1024M,max:1024M
GRUB_CMDLINE_XEN=

save and exit

now issue

update-grub

reboot once complete.

HowTo: Install XEN Dom0 on CentOS 6 from source

HowTo: Install XEN Dom0 on CentOS 6 from source

xen logo

This article assumes you have a clean install of CentOS and have root level access to the server. Note this was performed on a minimal install with no desktop.

Prereqs

To be able to perform a successful kernel build, you will need to install the following packages:

yum groupinstall “Development tools” “Compatibility libraries”

yum install transfig wget texi2html libaio-devel dev86 glibc-devel e2fsprogs-devel gitk mkinitrd iasl xz-devel bzip2-devel pciutils-libs pciutils-devel SDL-devel libX11-devel gtk2-devel bridge-utils PyXML qemu-common qemu-img mercurial texinfo libuuid-devel openssl-devel python-twisted python python-devel ncurses-devel gcc gettext yajl jajl-devel patch yajl yajl-devel

We also need the 32 bit version of glibc-devel.i686

yum install glibc-devel.i686

XEN Compile and install

Now lets get the XEN tarball and make XEN

cd /usr/src

wget http://bits.xensource.com/oss-xen/release/4.7.0/xen-4.7.0.tar.gz

tar xvf xen-4.7.0.tar.gz

cd xen-4.7.0

./configure -enable-githttp -libdir=/usr/lib

make xen

make tools

make stubdom

cd dist/install

cp -R * /

vi /etc/sysconfig/xendomains and comment out #XENDOMAINS_SAVE=/var/lib/xen/save

These tweeks should make XEN start at system startup and also create the bridge we need for the DomUs.

ln -s /etc/init.d/xendomains /etc/rc0.d/S10xendomains

ln -s /etc/init.d/xendomains /etc/rc6.d/S10xendomains

ln -s /etc/init.d/xencommons /etc/rc3.d/S98xencommons

ln -s /etc/init.d/xendomains /etc/rc3.d/S98xendomains

ln -s /root/xendom0caps /etc/rc3.d/S98xendom0caps

ln -s /root/iptables-enable /etc/rc3.d/S99iptables-enable (not required)

vi /root/xendom0caps (add xl sched-credit -d Domain-0 -w 512)

chmod +x /root/xendom0caps

vi /etc/rc.local (add /usr/bin/setterm -powersave off -blank 0)

vi /etc/xen/xl.conf (disable autoballon)

find line (network-script network-bridge) and comment out

#network-script network-bridge

Interfaces

As newer versions of XEN can use the system bridge rather than its own script we need to edit the network configuration to invoke our new bridge. Firstly create our new bridge interface. Replace the IP values with your settings.

cd /etc/sysconfig/network-scripts

vi ifcfg-xenbr0

DEVICE=”xenbr0″
NM_CONTROLLED=”yes”
ONBOOT=yes
TYPE=Bridge
BOOTPROTO=none
IPADDR=172.20.1.73
PREFIX=16
GATEWAY=172.20.0.76
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=”System xenbr0″

Now we need to edit ifcfg-eth0 and comment out the IP address and add the bridge in.

vi ifcfg-eth0

DEVICE=”eth0″
BOOTPROTO=”none”
NM_CONTROLLED=”yes”
ONBOOT=”yes”
#IPADDR=172.20.1.73
#GATEWAY=172.20.0.76
#NETMASK=255.255.0.0
TYPE=”Ethernet”
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=”System eth0″
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
BRIDGE=xenbr0

Once both files are done reboot to ensure they both apply successfully.

Kernel Compile

Now XEN is complete we need to get our kernel for Dom0. Replace the kernel number with the version you want to use.

(Please note the kernel version maybe significantly newer than detailed here)

cd /usr/src

wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.2.tar.gz

tar xvf linux-4.2.tar.gz

cd linux-4.2

make menuconfig

Go into Processor type and features

pic1

Statically enable all XEN features

pic21

Go back to the main menu and enter Device Drivers menu, then enter block devices menu

pic3

Statically enable the 2 XEN options

pic4

Go back to the Device Drivers menu and go down to XEN driver support

pic5

Statically enable all features

pic7

Go back to Device Drivers, go into Network device support and statically enable the 2 XEN options at the bottom

pic8

Exit out and save.

Note to make sure all options are selected run

cat /usr/src/linux-4.2.0/.config | grep XEN

You should see the same as

CONFIG_XEN=y
CONFIG_XEN_DOM0=y
CONFIG_XEN_PRIVILEGED_GUEST=y
CONFIG_XEN_PVHVM=y
CONFIG_XEN_MAX_DOMAIN_MEMORY=500
CONFIG_XEN_SAVE_RESTORE=y
CONFIG_XEN_DEBUG_FS=y
CONFIG_PCI_XEN=y
CONFIG_XEN_PCIDEV_FRONTEND=y
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_BLKDEV_BACKEND=y
CONFIG_NETXEN_NIC=m
CONFIG_XEN_NETDEV_FRONTEND=y
CONFIG_XEN_NETDEV_BACKEND=y
CONFIG_INPUT_XEN_KBDDEV_FRONTEND=y
CONFIG_HVC_XEN=y
CONFIG_HVC_XEN_FRONTEND=y
# CONFIG_XEN_WDT is not set
CONFIG_XEN_FBDEV_FRONTEND=y
CONFIG_XEN_BALLOON=y
CONFIG_XEN_BALLOON_MEMORY_HOTPLUG=y
CONFIG_XEN_SCRUB_PAGES=y
CONFIG_XEN_DEV_EVTCHN=y
CONFIG_XEN_BACKEND=y
CONFIG_XENFS=y
CONFIG_XEN_COMPAT_XENFS=y
CONFIG_XEN_SYS_HYPERVISOR=y
CONFIG_XEN_XENBUS_FRONTEND=y
CONFIG_XEN_GNTDEV=y
CONFIG_XEN_GRANT_DEV_ALLOC=y
CONFIG_SWIOTLB_XEN=y
CONFIG_XEN_PCIDEV_BACKEND=y
CONFIG_XEN_PRIVCMD=y
CONFIG_XEN_ACPI_PROCESSOR=y

If it looks good then continue otherwise please correct before hand.

make bzImage

make modules

make modules_install

cp -a arch/x86/boot/bzImage /boot/vmlinuz-4.2.0

cp -a System.map /boot/System.map-4.2.0

cp -a .config /boot/config-4.2.0

depmod –a

mkinitrd -o /boot/initrd.img-4.2.0 4.2.0

Modify GRUB to boot in XEN mode

vi /boot/grub/grub.conf

scroll down to the current setting and add the following above your current boot config, you will need to edit the lines to match your root and paths to the files.

title Xen 4.5.1 / Debian GNU/Linux, kernel 4.2.0
root (hd0,0)
kernel /xen.gz
module /vmlinuz-4.2.0 root=root=UUID=03f9e700-ba18-41a1-bbe7-65a372716c73 ro console=tty0
module /initrd.img-4.2.0

save and reboot.

If your system fails to boot then you can boot back into the normal kernel and correct any issues.

Once the system is booted run this as a simple test to make sure XEN is running

xl list

How to: Add autodiscover record using WHM

How to: Add autodiscover record using WHM

whm logo

In order to let Outlook clients such as 2010, 2013 to automatically set up your account and apply the correct settings, an Autodiscovery SRV record now needs to be added. In particular with Outlook 2016 this is now mandatory otherwise you can’t use it.

If you are using the WHM management suite and have access to edit the domains then you can easily accomplish this by following the steps below.

1. Open WHM and login.
2. Click on DNS Functions then scroll down to the domain you want to edit
3. Now where is says Add New Entries, add the following into the first section:

_autodiscover._tcp

4. No need to edit the TTL records but you can of course if you want to, the is default 14400 seconds.
5. Next choose SRV where is says to select.
6. Enter the priority:

0

7. Enter the Weight:

0

8. Enter the Port as:

443

9. Enter the FQDN of the exchange server that your host has given you with the full stop at the end:

outlook.domains.com.

10. Save the settings.

11. Now give it a little time to update then you can use this useful tool from Microsoft:

https://testconnectivity.microsoft.com/

12. If you dont want to use Microsofts tools then run this in a command prompt (Windows)

nslookup -q=srv _autodiscover._tcp.yourdomain.com

 

 

 

How To: Start Your Own Radio Station With SHOUTcast

How To: Start Your Own Radio Station With SHOUTcast

shoutcast logo

Starting your own SHOUTcast radio station can be just a dream for a lot of people due to the potentially expensive equipment required to get up and running, however these days it can be very simple. There are various ways of starting a radio station, the most popular method today is using the internet.

The majority of the population today have access to the internet on some sort of device, where it be a laptop, tablet or smart phone, this opens up so much potential to reach your audience without the need to transmit accross the airwaves.

In order to get your radio station up and running will require some key ingredients that when put together gives you scope for so much poential.

You will need:-

  1. A SHOUTcast Server – the hub where your listeners will connect to and listen in.
  2. Winamp – the source plays the music from your desktop/laptop machine.
  3. SHOUTcast DSP plugin – a plugin for Winamp which converts the music and connects to the SHOUTcast server so your listeners can hear.
  4. A good internet connection
  5. Music of course!

We will quickly cover the items required

SHOUTcast Server

A mentioned this is basically the hub where you as the broadcaster will upload your music to, which in turn allows the listeners to also connect to and listen to your stream. You can purchase your SHOUTcast server from TidyHosts, there are a number of packages to choose from.

Winamp

This is the software that needs to be installed on your desktop/laptop. You can download from http://www.winamp.com/ Once installed you then need to create your playlist that will be streamed for your audience to listen to. Of course you are not limited to files, you can connect external equipment such as CDJs and peform live shows. Please visit http://forums.winamp.com for more details on how to setup your equipment for use with Winamp.

SHOUTcast DSP plugin

Now that you have the server and Winamp installed its time to get the plugin that actually encodes and sends your stream to the server. Without this vital of software you wont be streaming anytime soon. You can download the plugin from http://www.shoutcast.com/BroadcastNow There is a useful guides on the forums at http://forums.winamp.com that show you how to install and setup the plugin for use on your machine.

A Good Internet Connection

If you plan to stream at a good quality bitrate such as 320 kbps then you will need a good and stable internet connection. We cannot stress enough how important this is. If your connection is known for drops then you will quickly lose your audience. The automated SHOUTcast directory may block the listing in the directory if it detects flapping so before starting out make sure this in good shape.

Music of Course

You have got everything ready, server is up, PC is up, all you need now is quality music for your listeners. What you stream is entirely up to you, make sure it is clear and can be easily heard. Having your input volume to low will put listeners off whislt having it too high will cause distortion so test with friends before starting off. Once you have decided what you want to broadcast, try and do some online advertising using social media such as Facebook and Twitter etc. Remember, word of mouth is a great advertising tool, produce a great show and the listeners will increase before you know it!