header image
 

How to Cleanup WordPress MySQL ClearDB that is running on Azure




Greetings folks,

last year decided to move my blog from WordPress.com to WordPress running on Azure, see here:

http://luisrato.azurewebsites.net/2014/06/07/how-to-migrate-wordpress-com-blog-to-wordpress-hosted-on-azurepart-1/

With a Blog for personal use I definitely have the Cost in mind, so I am running my WordPress site with the default MySQL Database from ClearDB with a Free quota of… 20Mb.

Everything has been running smoothly and flawlessly, however as any Publicly available WordPress Blog it is targeted for SPAM, obviously I have all sorts of security mitigations in place but all that Junk and associated metadata keeps bloating the Database.

As son as I got above ~80% of ClearDB 20Mb quota I received an email warning notification, but when I’ve reached the limit an Urgent notification was sent to inform that the Database was set to read-only, something such as this:

===================

Subject: [URGENT] ClearDB database size quota limit notification

Body:

“Hello Luís Rato,
Thanks ….

Database: Mydatabase
Tier/Plan: Mercury
Tier size quota: 20 MB

Please note that the use of temporary tables as well as index sizes are included in our storage size calculations.
This database has either reached or has exceeded its maximum allowed size for the ‘Mercury’ plan/tier that it currently belongs to. As such, our systems were forced to disable write privileges to it.…”

===========================

From this point I was unable to create new content, comments, etc on my WordPress website, but it got worst as I was unable to login with my Credentials.

This particular Post will explain you how to Cleanup the ClearDB Database that is supporting the WordPress site running on Azure, all the SQL Statements can be used for other SQL Databases as needed.

Here is a brief description of what we will do:

  1. Install MySQL Tool WorkBench
  2. Get the MySQL ClearDB login information from Azure portal
  3. Create and establish a MySQL ClearDB connection with Workbench
  4. Run the SQL Statements on WorkBench for WordPress Database Cleanup

1. Download and Install MySQL Tool WorkBench

1. Install MySQL Workbench Prerequisites:

2. Download and Install MySQL WorkBench
http://dev.mysql.com/downloads/workbench/


2. Get the MySQL ClearDB login information from Azure portal

You get your ClearDB login information through the new or old Azure Portal, chose what’s best for you (I prefer the new portal…).

[NEW AZURE PORTAL]

1. Login to the new Azure Portal: https://manage.windowsazure.com

2. Browse –> Resource Groups –> Default-ClearDB-WestEurope

3. Click your MySQL Databases icon

4. Click on Properties and see the required information on the image

image4

[OLD AZURE PORTAL]

1. On the Left hand side click on Sites –> Click on your <web site name>

2. On the Web sites dashboard screen on the top menu click on Linked Resources

3. Then on the next screen click on your MySQL <Database name>

You will be redirected to ClearDB Website (https://www.cleardb.com/database/…)

4. On the ClearDB Website top menu click on Endpoint Information

5. The top table on the screen shows you the Hostname, on the bottom left of the screen you have the required login information for user and password.

image5

3. Create and establish a MySQL ClearDB connection with Workbench

1. Open Workbench and on the top left of the screen on My SQL Connections section click on the [+] sign to setup a new connection

2. On the Setup new connection screen fill the login information from ClearDB that you collected through Azure Portal or ClearDB Website. When finished click on Ok.

image1

3. When you finish the connection setup a new square button will appear on the top left on the screen, just click on it to login to your MySQL Database ClearDB

image2

 

4. Run the SQL Statements on WorkBench for WordPress Database Cleanup

For each Cleanup step you have two SQL statements, one SELECT so that before deletion you can evaluate the targeted cleanup information, and next you have the DELETE statement that will flush the content from the database, don’t run both at the same time so that you can validate first.

Before you start on the bottom left of the Workbench screen double-click on the database name so that the SQL statements are run on the Database context.

image6



1. Clean up “wp_comments” table with SPAM entries

SELECT * FROM wp_comments
WHERE wp_comments.comment_approved = 'spam';

DELETE FROM wp_comments
WHERE wp_comments.comment_approved = 'spam';

2. Clean up “wp_posts” table with Post revision entries that are no longer necessary

SELECT * FROM wp_posts
WHERE post_type = "revision";

DELETE FROM wp_posts
WHERE post_type = "revision";

3. Clean up “wp_commentmeta” table entries which have no relation to wp_comments


SELECT * FROM wp_commentmeta
WHERE comment_id NOT IN (
SELECT comment_id FROM wp_comments
)


DELETE FROM wp_commentmeta
WHERE comment_id NOT IN (
SELECT comment_id FROM wp_comments
)

4. Clean up “wp_commentmeta” table metadata related to Akismet Antispam

SELECT * FROM wp_commentmeta
WHERE meta_key LIKE "%akismet%"

DELETE FROM wp_commentmeta
WHERE meta_key LIKE "%akismet%"

 

R-Tape Loading error,
Luís Rato


How to Install Android x86 4.4 R2 on Hyper-V – Part 2: Configuration, Screen resolution and Network (Jan 2015)




Completing the series with the Part 2 of ‘How to install Android x86 4.4 R2 on Hyper-V’.

On my last Post “How to install Android x86 4.4 R2 on Hyper-V – Part 1: Install” we had:

– Phase 1: Download Android x86 4.4 R2 and prepare a VM to run it
– Phase 2: Install Android x86 4.4 R2 on a VM

On this post I’ll cover:

– Phase 3: Run and Configure Android x86 for the first time
– Phase 4: Advanced settings – Screen resolution
– Phase 5: Advanced settings – Network configuration

 

Phase 3: Run and Configure Android x86 for the first time

When you boot the Android VM for the first time you need to configure the initial settings.

Before you start make sure you Eject the ISO image from the VM.

1. Ignore the Bluetooth warning and click “Ok” and select the preferred Language option “English United-States

boot

boot1

2. Ignore the Wifi Selection and click “Skip” and on the next screen confirm that by selecting “Skip anyway

boot2

boot3

3. If the Hyper-V vSwitch assigned to your Android VM is connected to the external network with Internet access and has a DHCP Server to assign IP Address configuration automatically you can choose “Yes” and accept the Terms to configure your Google account, if not click “No” to skip this.

boot4

4. Add your Google account sign in information.

boot5

5. On Google services click on the Down arrow and Right arrow afterwards.

boot6

6. You can skip the Payment info by clicking on “NOT NOW

boot7

7. On the Table info insert the desired name.

boot8

8. On the Welcome screen click “OK” and “OK” again

boot9

boot10

Phase 4: Advanced settings – Screen resolution

Android-x86 default config has been made for smaller form factors and screen resolutions, running it with the defaults on your VM environment is unpractical.

To change the screen resolution you need to accomplish the following:

– Determine what’s the best screen resolution for you
– Test the new screen resolution
– Make persistent changes of the new screen resolution
– Modify the font size of the Terminal Emulator

1. Determine what’s the best screen resolution for you

1.1  Start the VM and In the GRUB menu press the [a] key

1.2  In the next screen append vga=ask and press [Enter], on the next screen press [Enter] again

screen

You will be presented with the possible screen resolutions. Each resolution is defined by an hex value on the ‘Mode’ column (see below).

Example: 1024×768 16 bits has the hex value of ‘317’, however to use this screen resolution you need to convert the value from hex to decimal.

image

1.3 Determine what is your convenient Screen resolution through the following table, on the Mode Decimal column you have the appropriate value that you’ll use on testing and configuration.

 


Mode (hex): Mode Decimal Resolution Type Mode (hex): Mode Decimal Resolution Type
F00 3840 80×25 VGA F01 3841 80×50 VGA
F02 3842 80×43 VGA F03 3843 80×28 VGA
F05 3845 80×30 VGA F06 3846 80×34 VGA
F07 3847 80×60 VGA 300 768 600x400x8 VESA
301 769 640x480x8 VESA 311 785 640x480x16 VESA
312 786 640x480x32 VESA 326 806 800x512x8 VESA
327 807 800x512x16 VESA 328 808 800x512x32 VESA
303 771 800x600x8 VESA 314 788 800x600x16 VESA
315 789 800x600x32 VESA 329 809 896x600x8 VESA
32A 810 896x600x16 VESA 32B 811 896x600x32 VESA
305 773 1024x768x8 VESA 317 791 1024x768x16 VESA
318 792 1024x768x32 VESA 31D 797 1024x768x8 VESA
32C 812 1152x768x8 VESA 32D 813 1152x768x16 VESA
32E 814 1152x768x32 VESA 307 775 1280x1024x8 VESA
31A 794 1280x1024x16 VESA 324 804 1600x1024x8 VESA
325 805 1600x1024x16 VESA 320 800 1600x1200x8 VESA
322 802 1600x1200x16 VESA

2. Test the new screen resolution

I recommend that you test the screen resolution before you do the permanent changes. Example with a screen resolution of 1024x768x16 the configuration decimal value is ‘791’.

2.1 Start the VM and In the GRUB menu press the [a] key

2.2  In the next screen append vga=791 and press [Enter]

Android VM will start with the screen resolution of 1024×768 16 bits, if this is not the best configuration for yourself you can repeat the process with other resolution decimal value.

3. Make persistent changes of the new screen resolution

We will make persistent changes for screen resolution through GRUB, for that we need to mount the image and edit the ‘menu.lst’.

3.1 Start the Android VM and from the GRUB menu select ‘Debug Mode’

3.2 Type the following to mount the image and edit GRUB ‘menu.lst’:

# mount -o remount,rw /mnt
# cd /mnt/grub
# vi menu.lst

image18

3.3. Modify the GRUB menu boot option (menu.lst) with the appropriate screen resolution

For that you need to append to the identified line on the image below the value ‘vga=791’ (hex value would be 317 for the screen resolution 1024x768x16):

image19

We will be using the ancient Unix editor Vi (http://www.cs.rit.edu/~cslab/vi.html), if you are not familiar you should know that editing a file with Vi is not as simple as Windows Notepad or other Linux editors (e.g. nano), so please do the following:

– Move the cursor to the start of the line mentioned on the above image

– Press the keys [SHIFT] + [A] to start the file editing mode

– Append ‘vga=791’ to the end of that line, you should end up with something like this (single line):

kernel /android-4.4-R2/kernel root=/dev/ram0 androidboot.hardware=android_x86 SRC=/android-4.4-RC2 vga=791

– When finished press the [ESC] key to exit the edit mode

– Save changes and quit with ‘:wq

Tip: Typing ‘:q’ woucd ld quit if no changes were done, ‘:q!’ would quit and discard any changes.

3.4 Unmount the image and reboot:

cd /
umount /mnt
reboot -f

On the next boot you will have the new screen resolution set.

4. Modify the Font size on the Terminal emulator

If you open the Terminal Emulator on it’s default font size you will get a very tiny Font size and you can barely read anything, so let’s adjust this.

4.1 Start your Android x86 VM, unlock the screen, click on the Apps button and open the “Terminal Emulator” on the Apps menu

settings

settings1

4.2 Click on the Top right button to slide down the menu options and select ‘Preferences

settings2

4.3 On the ‘Preferences’ screen click on ‘Font size

settings3

4.4 Now select your preferred Font size (reasonable size would be between 12 – 16pt) and clock on the Back button (bottom left) to return to the Terminal screen with the newer font size

settings4

Phase 5: Advanced settings – Network configuration

You can configure Android x86 network automatically through DHCP or manually. Manual network configuration will disappear every time you reboot Android x86 and you’ll need to repeat the network configuration. Due to this limitation I recommend that you configure Android x86 network settings automatically through DHCP.

To configure my network I can chose one of the following options:

– Automatic Network configuration through DHCP
– Manual Network configuration through terminal

For your better understanding I will use this network settings during the Terminal configuration:

IP: 192.168.1.20
Netmask: 255.255.255.0
Gateway: 192.168.1.1
DNS: 192.168.1.1

1. Automatic Network configuration through DHCP

If you have a DHCP Server on the same Network as your Android x86 the network settings should be set automatically.

1.1 Start your Android x86 VM, unlock the screen, click on the Apps button and open the “Terminal Emulator” on the Apps menu

settings

settings1

1.2 Verify your Network configuration settings

On Terminal run the following to verify your network settings:

ip a

image

You can also use netcfg to verify the NIC (eth0) state:

netcfg

image

Note: I’ve seen some situations where particular
routers (e.g. Linksys with dd-wrt firmwares) send invalid UDP packets and the Android x86 can’t pick the IP Address configuration. If that’s the case you can try the following in Terminal, if this either fails you need to connect to a different DHCP Server source or define your Network Settings manually.

adb shell
su
dhcpcd -k eth0                –> Release
dhcpcd -n eth0                –> Renew

2. Manual Network configuration through terminal

On Terminal run the following to configure your network settings:

adb shell
su

ifconfig eth0 192.168.1.20 netmask 255.255.255.0 up
route add default gw 192.168.1.1 dev eth0
setprop net.dns1 192.168.1.1

We had to use the Android Debug Bridge (adb) to allow you to communicate with Emulator, enable root access (su),  only after this you can configure your IP Address/netmask (ifconfig), default gateway (routeadd) and dns (setprop).

Verify your networking settings with:

ip a

image

Android x86 does not support ethernet persistent network settings, after reboot you need to run the same terminal commands to configure your machine.

This completes the series of “How to install Android x86 4.4 R2 on Hyper-V”.

R-Tape Loading error,
Luís Rato


How to install Android x86 4.4 R2 on Hyper-V – Part 1: Install (Jan 2015)

Hi there guys,

on 1st Jan 2015 Android-x86.org has made available the latest release of Android x86 R2, there are a bunch of bug fixes and improvements and one of the good advancements is the native support for Hyper-V with all the required modules and synthetic drivers preloaded.

As you can see on a previous post related to the “RC2” release there was no native support for Hyper-V at that time which turned the installation process much more complex.

I will keep the above post available as the described process can be useful for reference.

 

Part 1: How to install Android x86 4.4 RC2 on Hyper-V: Install

– Phase 1: Download Android x86 4.4 and prepare a VM to run it
– Phase 2: Install Android x86 4.4 on a VM

 

Part 2: How to Install Android x86 4.4 R2 on Hyper-V: Configuration, Screen resolution and Network

– Phase 3: Run and Configure Android x86 for the first time
– Phase 4: Advanced settings – Screen resolution
– Phase 5: Advanced settings – Network configuration

Phase 1: Download Android x86 4.4 R2 and prepare a VM to run it

1. Download Android ISO: http://www.android-x86.org/releases/releasenote-4-4-r2

 


Android Live and Installation ISO
Version: 4.4 R2 (KitKat-MR2.2 4.4.4 r2 release)
File name: android-x86-4.4-r2.iso
Size: 388.0MB
SHA1: 3b7acd23d3feb87ed13a2c5f489ea1a3f254f809

2. Open the Hyper-V Manager to Create a Virtual Switch for your Virtual environment Network

On the right pane Click “Virtual Switch Manager

Create an “Internal” or “External” Virtual Switch depending on your network needs

3. On the Hyper-V Manager create a new Virtual Machine and Virtual Hard Disk:

On the right-pane Actions menu Click “New” –>Virtual Machine

On the New Virtual Machine Wizard –> Next

Define the Machine Machine Name “Android 4.4 R2” and the desired location of the Virtual Machine configuration files

If your are running a Windows 8.1 or Windows Server 2012 R2 host Select the Virtual Machine “Generation 1

Set the Memory size “1024” MB (add more if needed) and enable “Use Dynamic memory for this Virtual Machine” by ticking the Checkbox

Select the Virtual Switch Network (I will use my “External” vSwitch)

Create a Virtual Hard Disk (default: differential) with no more than “8GB” (should be enough…)

Select “Install Operating System from a Boot CD/DVD” and Select the Android “image file (ISO)”

Review the VM configuration and click “Finish” to complete the VM creation

Phase 2: Install Android x86 4.4 R2 on a VM

1. Start the VM and on the Boot menu select “Installation – Install Android-x86 to harddisk

install

2. After boot Press [ENTER] on the default option “Create Modify partition” and press “OK

3. On Cfdisk partition configuration select “New” and next select “Primary

install5

install6

4. Confirm the Volume size (e.g 8587.20MB) and mark the Partition as “Bootable” through the menu options

install7

install8

5. Select “Write” and confirm “yes” to write the partition table to disk and select “Quit” to complete

install9

install10

6. Select the new partition installation partition “sda1” and the File system format “ext3

install11

install12

7. Confirm the partition format “Yes” and confirm the GRUB boot loader install with “Yes

install13

install14

8. Confirm the read-write directory with “Yes” and wait a few seconds for the installation to complete.

install15

9. Following the last step you will see a screen confirming that the installation was successful.

Select the option “Run Android-x86” to launch Android and start the initial configuration.

install16

This completes the Part 1 of “How to install Android x86 4.4 R2 on Hyper-V”. You can access the “Part 2: How to Install Android x86 4.4 R2 on Hyper-V – Part 2: Configuration, Screen resolution and Network”.

R-Tape Loading error,
Luís Rato

How to change the Video resolution on a Kali Linux VM running on Hyper-V




Hi there guys,

recently I had a post feedback reporting the struggle of being unable to change the Video resolution of Kali Linux running on Hyper-V.

You can’t change Video resolution settings on Hyper-V Manager or on a VM configuration, no matter if it is Windows or Linux (something to improve for sure…).

On Windows it is not a big issue because you connect to a Windows VM through RDP protocol and from there you can change to the desired Video resolution.

So what about Linux… well, Microsoft has made available the Microsoft Hyper-V Video Synthetic driver “hyperv_fb” which has been integrated on the latest Linux Kernel.

When you boot your Kali Linux VM you will get a video resolution of 1152×864 as you can see here:

image4

While running lsmod on Terminal you can verify that the “hyperv_fb” module is loaded by default:

image1

So here’s the deal, we have the Video synthetic driver already loaded, we just need to force the video resolution settings on the GRUB boot loader with the following steps:



1. Open Terminal and type:

sudo vi /etc/default/grub

2. Scroll down to the line GRUB_CMDLINE_LINUX_DEFAULT=”quiet” and press the [i] Key to enable the Insert function on Vi editor

3. Change the resolution configuration for the Hyper-V Video Synthetic driver (in this case I will use 1280×720) with the following:

GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash video=hyperv_fb:1280×720″

4. Write changes and quit Vi:

Press the [Esc] Key
Type [:wq]  –> Without brackets

5. Update the Grub configuration:

sudo update-grub

6. Reboot the virtual machine

restart

You can confirm these changes by going through:

Applications menu –> System Tools –>Preferences –> System Settings

image3

image5

 

R-Tape Loading error,
Luís Rato


How to Install Android x86 4.4 RC2 on Hyper-V – Part 2: Configuration, Screen resolution and Network



Completing the series with the Part 2 of ‘How to install Android x86 4.4 RC2 on Hyper-V’.

On my last Post “How to install Android x86 on Hyper-V – Part 1: Install” we had:

– Phase 1: Download Android x86 4.3 and prepare a VM to run it
– Phase 2: Install Android x86 4.3 on a VM
– Phase 3: Run and Configure Android x86 for the first time

On this post I’ll cover:

– Phase 4: Run and Configure Android x86 for the first time
– Phase 5: Advanced settings – Screen resolution
– Phase 6: Advanced settings – Network configuration

 

Phase 4: Run and Configure Android x86 for the first time

When you boot the Android VM for the first time you need to configure the initial settings.

Before you start make sure you Eject the ISO image from the VM.

1. Ignore the Bluetooth warning and click “Ok” and select the preferred Language option “English United-States

boot

boot1

2. Ignore the Wifi Selection and click “Skip” and on the next screen confirm that by selecting “Skip anyway

boot2

boot3

3. If the Hyper-V vSwitch assigned to your Android VM is connected to the external network with Internet access and has a DHCP Server to assign IP Address configuration automatically you can choose “Yes” and accept the Terms to configure your Google account, if not click “No” to skip this.

boot4

4. Add your Google account sign in information.

boot5

5. On Google services click on the Down arrow and Right arrow afterwards.

boot6

6. You can skip the Payment info by clicking on “NOT NOW

boot7

7. On the Table info insert the desired name.

boot8

8. On the Welcome screen click “OK” and “OK” again

boot9

boot10

 

 

Phase 5: Advanced settings – Screen resolution

Android-x86 default config has been made for smaller form factors and screen resolutions, running it with the defaults on your VM environment is unpractical.

To change the screen resolution you need to accomplish the following:

– Determine what’s the best screen resolution for you
– Test the new screen resolution
– Make persistent changes of the new screen resolution
– Modify the font size of the Terminal Emulator

1. Determine what’s the best screen resolution for you

1.1  Start the VM and In the GRUB menu press the [a] key

1.2  In the next screen append vga=ask and press [Enter], on the next screen press [Enter] again

screen

You will be presented with the possible screen resolutions. Each resolution is defined by an hex value on the ‘Mode’ column (see below).

Example: 1024×768 16 bits has the hex value of ‘317’, however to use this screen resolution you need to convert the value from hex to decimal.

image

1.3 Determine what is your convenient Screen resolution through the following table, on the Mode Decimal column you have the appropriate value that you’ll use on testing and configuration.

Mode (hex): Mode Decimal Resolution Type Mode (hex): Mode Decimal Resolution Type
F00 3840 80×25 VGA F01 3841 80×50 VGA
F02 3842 80×43 VGA F03 3843 80×28 VGA
F05 3845 80×30 VGA F06 3846 80×34 VGA
F07 3847 80×60 VGA 300 768 640x400x8 VESA
301 769 640x480x8 VESA 311 785 640x480x16 VESA
312 786 640x480x32 VESA 326 806 800x512x8 VESA
327 807 800x512x16 VESA 328 808 800x512x32 VESA
303 771 800x600x8 VESA 314 788 800x600x16 VESA
315 789 800x600x32 VESA 329 809 896x600x8 VESA
32A 810 896x600x16 VESA 32B 811 896x600x32 VESA
305 773 1024x768x8 VESA 317 791 1024x768x16 VESA
318 792 1024x768x32 VESA 31D 797 1024x768x8 VESA
32C 812 1152x768x8 VESA 32D 813 1152x768x16 VESA
32E 814 1152x768x32 VESA 307 775 1280x1024x8 VESA
31A 794 1280x1024x16 VESA 324 804 1600x1024x8 VESA
325 805 1600x1024x16 VESA 320 800 1600x1200x8 VESA
322 802 1600x1200x16 VESA

2. Test the new screen resolution

I recommend that you test the screen resolution before you do the permanent changes. Example with a screen resolution of 1024x768x16 the configuration decimal value is ‘791’.

2.1 Start the VM and In the GRUB menu press the [a] key

2.2  In the next screen append vga=791 and press [Enter]

Android VM will start with the screen resolution of 1024×768 16 bits, if this is not the best configuration for yourself you can repeat the process with other resolution decimal value.

3. Make persistent changes of the new screen resolution

We will make persistent changes for screen resolution through GRUB, for that we need to mount the image and edit the ‘menu.lst’.

3.1 Start the Android VM and from the GRUB menu select ‘Debug Mode

3.2 Type the following to mount the image and edit GRUB ‘menu.lst’:

# mount -o remount,rw /mnt
# cd /mnt/grub
# vi menu.lst

screen1

3.3. Modify the GRUB menu boot option (menu.lst) with the appropriate screen resolution

For that you need to append to the identified line on the image below the value ‘vga=791’ (hex value would be 317 for the screen resolution 1024x768x16):

screen2

We will be using the ancient Unix editor Vi (http://www.cs.rit.edu/~cslab/vi.html), if you are not familiar you should know that editing a file with Vi is not as simple as Windows Notepad or other Linux editors (e.g. nano), so please do the following:

– Move the cursor to the start of the line mentioned on the above image

– Press the keys [SHIFT] + [A} to start the file editing mode

– Append ‘vga=791’ to the end of that line, you should end up with something like this (single line):

kernel /android-4.4-RC2/kernel root=/dev/ram0 androidboot.hardware=android_x86 video=-16 SRC=/android-4.4-RC2 vga=791

– When finished press the [ESC] key to exit the edit mode

– Save changes and quit with ‘:wq

Tip: Typing ‘:q’ woucd ld quit if no changes were done, ‘:q!’ would quit and discard any changes.

3.4 Unmount the image and reboot:

cd /
umount /mnt
reboot -f

On the next boot you will have the new screen resolution set.

4. Modify the Font size on the Terminal emulator

If you open the Terminal Emulator on it’s default font size you will get a very tiny Font size and you can barely read anything, so let’s adjust this.

4.1 Start your Android x86 VM, unlock the screen, click on the Apps button and open the “Terminal Emulator” on the Apps menu

settings

settings1

4.2 Click on the Top right button to slide down the menu options and select ‘Preferences

settings2

4.3 On the ‘Preferences’ screen click on ‘Font size

settings3

4.4 Now select your preferred Font size (reasonable size would be between 12 – 16pt) and clock on the Back button (bottom left) to return to the Terminal screen with the newer font size

settings4

 

Phase 6: Advanced settings – Network configuration

You can configure Android x86 network automatically through DHCP or manually. Manual network configuration will disappear every time you reboot Android x86 and you’ll need to repeat the network configuration. Due to this limitation I recommend that you configure Android x86 network settings automatically through DHCP.

To configure my network I can chose one of the following options:

– Automatic Network configuration through DHCP
– Manual Network configuration through terminal

 

For your better understanding I will use this network settings during the Terminal configuration:

IP: 192.168.1.20
Netmask: 255.255.255.0
Gateway: 192.168.1.1
DNS: 192.168.1.1

1. Automatic Network configuration through DHCP

If you have a DHCP Server on the same Network as your Android x86 the network settings should be set automatically.

1.1 Start your Android x86 VM, unlock the screen, click on the Apps button and open the “Terminal Emulator” on the Apps menu

settings

settings1

1.2 Verify your Network configuration settings

On Terminal run the following to verify your network settings:

ip a

image

You can also use netcfg to verify the NIC (eth0) state:

netcfg

image

Note: I’ve seen some situations where particular
routers (e.g. Linksys with dd-wrt firmwares) send invalid UDP packets and the Android x86 can’t pick the IP Address configuration. If that’s the case you can try the following in Terminal, if this either fails you need to connect to a different DHCP Server source or define your Network Settings manually.

adb shell
su
dhcpcd -k eth0                –> Release
dhcpcd -n eth0                –> Renew

2. Manual Network configuration through terminal

On Terminal run the following to configure your network settings:

adb shell
su

ifconfig eth0 192.168.1.20 netmask 255.255.255.0 up
route add default gw 192.168.1.1 dev eth0
setprop net.dns1 192.168.1.1

We had to use the Android Debug Bridge (adb) to allow you to communicate with Emulator, enable root access (su),  only after this you can configure your IP Address/netmask (ifconfig), default gateway (routeadd) and dns (setprop).

Verify your networking settings with:

ip a

image

Android x86 does not support ethernet persistent network settings, after reboot you need to run the same terminal commands to configure your machine.

 

This completes the series of “How to install Android x86 4.4 RC2 on Hyper-V”.

R-Tape Loading error,
Luís Rato

How to install Android x86 4.4 RC2 on Hyper-V – Part 1: Install


[UPdate]

This Post has been updated on 2015 for the Android x86 R2 which now natively supports Hyper-V, see here:

http://luisrato.azurewebsites.net/2015/01/02/how-to-install-android-x86-4-4-r2-on-hyper-v-part-1-install-jan-2015/

This post is maintained for future reference.

[/update]

Hi there folks,

Cloud adoption is moving surprisingly fast, with the so called strategy “mobile first, cloud first” I am frequently challenged to demo different business scenarios with Office 365 and Microsoft Azure services being consumed across multiple devices.

As enterprise customers are getting immersed into CYOD/BYOD policies I need to do showcases with different OS’s, so I have a dilemma, I need an additional non-Windows OS/Device but I don’t want to buy one.

With iOS I would need Apple devices – not an option, with Android I have Bluestacks for Android emulation which is a bit intrusive for my Laptop OS/Hyper-V Host or I can run a x86 ported version of Android on a VM, I prefer the latest.

I have already done this exercise before with Android 4.3 Jelly Bean, it has limitations and is a bit unstable and with Android 4.4 (KitKat) RC2 there are a lot of issues being addressed.

If you want to run Android 4.4 x86 RC2 on Hyper-V you will probably struggle a lot because of the Virtualization modules are not being loaded by default, to make the installation possible we need to accomplish some advanced tasks, even though if you follow the steps as described here there’s no room for failure.
Android x86 4.4 RC1 release note
Android x86 4.4 RC2 release note

 

Part 1: How to install Android x86 4.4 RC2 on Hyper-V: Install

– Phase 1: Download Android x86 4.4 and prepare a VM to run it
– Phase 2: Install Android x86 4.4 on a VM
– Phase 3: Loading Hyper-V modules permanently

 

Part 2: How to Install Android x86 4.4 RC2 on Hyper-V: Configuration, Screen resolution and Network

– Phase 4: Run and Configure Android x86 for the first time
– Phase 5: Advanced settings – Screen resolution
– Phase 6: Advanced settings – Network configuration

 

Phase 1: Download Android x86 4.4 RC2 and prepare a VM to run it

1. Download Android ISO: http://www.android-x86.org/releases/releasenote-4-4-rc2

 


Android Live and Installation ISO
Version: 4.4 RC2 (KitKat-MR1 4.4.2 release)
File name: android-x86-4.4-RC2.iso
Size: 348.1MB
SHA1: 3b7acd23d3feb87ed13a2c5f489ea1a3f254f809

2. Open the Hyper-V Manager to Create a Virtual Switch for your Virtual environment Network

On the right pane Click “Virtual Switch Manager

Create an “Internal” or “External” Virtual Switch depending on your network needs

3. On the Hyper-V Manager create a new Virtual Machine and Virtual Hard Disk:

On the right-pane Actions menu Click “New” –>Virtual Machine

On the New Virtual Machine Wizard –> Next

Define the Machine Machine Name “Android44” and the desired location of the Virtual Machine configuration files

If your are running a Windows 8.1 or Windows Server 2012 R2 host Select the Virtual Machine “Generation 1

Set the Memory size “1024” MB (add more if needed) and enable “Use Dynamic memory for this Virtual Machine” by ticking the Checkbox

Select the Virtual Switch Network (I will use my “External” vSwitch)

Create a Virtual Hard Disk (default: differential) with no more than “8GB” (should be enough…)

Select “Install Operating System from a Boot CD/DVD” and Select the Android “image file (ISO)”

Review the VM configuration and click “Finish” to complete the VM creation

 

Phase 2: Install Android x86 4.4 RC2 on a VM

1. Start the VM and on the Boot menu select “Installation – Install Android-x86 to harddisk

install

2. After boot Press [ENTER] on the default option “Create Modify partition

install1

3. As mentioned before the Hyper-V Storage driver (module “hv_storvsc”) is not loaded by default on the build Android 4.4 RC2, so when you click “OK” to create the partition the cfdisk (Linux partition editor) will fail to access the HDD and you’ll see the following error message:

FATAL ERROR: Cannot open disk drive
Press any Key to exit cfdisk

Press any key to exit the black error screen.

install2

4. On the next screen we are informed that the Installation failed.

To fix this we need to load the Hyper Storage module manually from the command Shell, to get there press [CONTROL] + [ALT] + [F2].

install3

5. On the Command Shell type the following to load the Hyper-V Storage Module “hv_storvsc

# modprobe storvsc

install4

Now press [CONTROL] + [ALT] + [F1] to exit command shell and return to the installation prompt

6. Back to the Installation failure message make sure you select “Retry” and press [ENTER] key

install3

7. You will be presented with “Choose Partition” screen, now you can select “Create/Modify partitions” and press “OK

install1

8. On Cfdisk partition configuration select “New” and next select “Primary

install5

install6

9. Confirm the Volume size (e.g 8587.20MB) and mark the Partition as “Bootable” through the menu options

install7

install8

10. Select “Write” and confirm “yes” to write the partition table to disk and select “Quit” to complete

install9

install10

11. Select the new partition installation partition “sda1” and the File system format “ext3

install11

install12

12. Confirm the partition format “Yes” and confirm the GRUB boot loader install with “Yes

install13

install14

13. Confirm the read-write directory with “Yes” and wait a few seconds for the installation to complete.

install15

14. Following the last step you will see a screen confirming that the installation was successful.

If you  select the option “Run Android-x86” it will fail because the Hyper-V modules are not preloaded by default. We need to make some permanent changes so that Hyper-V modules are loaded every time you boot your VM.

install16

Shut down the VM through the Hyper-V Manager console.

Phase 3: Loading Hyper-V modules permanently

 

If we attempt to boot the VM after the installation it will fail because the Hyper-V modules are not preloaded by default.

For reference, here is the list and location of each Hyper-V module/driver:

hv_vmbus: Hyper-v virtualization driver
/system/lib/modules/3.10.40-android-x86\+/kernel/drivers/hv/hv_vmbus.ko

hv_balloon: Hyper-v Dynamic memory driver
/system/lib/modules/3.10.40-android-x86\+/kernel/drivers/hv/hv_balloon.ko

hv_utils: Hyper-v integration services
/system/lib/modules/3.10.40-android-x86\+/kernel/drivers/hv/hv_utils.ko

hv_storvsc: Hyper-v Storage Syntethic driver
/system/lib/modules/3.10.40-android-x86\+/kernel/drivers/scsi/hv_storvsc.ko

hv_netvsc: Hyper-v Network Syntethic driver
/system/lib/modules/3.10.40-android-x86\+/kernel/drivers/net/hyperv/hv_netvsc.ko

hid_hyperv: Microsoft Vmbus HID-compliant Mouse
/system/lib/modules/3.10.40-android-x86\+/kernel/drivers/hid/hid-hyperv.ko

 

On the following steps we will make changes on the ‘init’ file so that Hyper-V modules/drivers are loaded in Kernel.

 

1. Boot the VM with the iso image loaded and select the option “Live CD – Debug mode” so that we get a command shell to execute the whole process.

permanent

2. On the Live CD Debug mode command shell we will load the Hyper-V Storage module “hv_storvsc” so that we can access our VM HDD and make permanent changes. For that execute the following command:

modprobe hv_storvsc

permanent1

3. Navigate to a writable folder and mount the Virtual Hard disk partition:

# cd data/
# mkdir mnt
# mknod sda1 b 8 1
# mount sda1 mnt

4. We will make a backup of initrd.img just in case we mess up with it and decompress all the content to a temporary directory:

# cp mnt/android-4.4-RC2/initrd.img initrd.img.bak
# mkdir initrd
# cd initrd/
# gunzip -c ../mnt/android-4.4-RC2/initrd.img | cpio -i

5. Copy all the required Hyper-V modules/drivers from the Live CD to the temporary initrd directory:

# cp /system/lib/modules/3.10.40-android-x86\+/kernel/drivers/hv/hv_vmbus.ko .
# cp /system/lib/modules/3.10.40-android-x86\+/kernel/drivers/hv/hv_balloon.ko .

# cp /system/lib/modules/3.10.40-android-x86\+/kernel/drivers/hv/hv_utils.ko .

# cp /system/lib/modules/3.10.40-android-x86\+/kernel/drivers/hid/hid-hyperv.ko .

# cp /system/lib/modules/3.10.40-android-x86\+/kernel/drivers/net/hyperv/hv_netvsc.ko .

# cp /system/lib/modules/3.10.40-android-x86\+/kernel/drivers/scsi/hv_storvsc.ko .

 

6. We need to install the Hyper-V loadable modules in the running Kernel by using insmod for each Hyper-v driver. We can do this by editing the ‘init’ file.

You have two options to do this, we can use the ‘sed’ tool to append the information on the ‘init’ file or we can use the ‘vi’ editor to edit the ‘init’ file directly.

 

Option 1: Using ‘sed’ to append each Hyper-v loadable module:

# sed -i -e ‘118i\insmod hv_vmbus.ko’ -e ‘118i\insmod hv_storvsc.ko’ -e ‘118i\insmod hv_netvsc.ko’ -e ‘118i\insmod hv_utils.ko’ -e ‘118i\insmod hv_balloon.ko’ -e ‘118i\insmod hid-hyperv.ko’ init

We need to load each module just before the line ‘echo –n Detecting Android-x86…’, on this build Android x86 4.4 RC2 the line just before that is the number 118, on future or prior builds that could be different, make sure you verify that and change accordingly if you are not running this build.

After running the above command with ‘sed’ if you edit the init file (vi init) you will notice that starting on the line 118 we have appended each Hyper-v module driver, here is the output:

permanent3

Option 2: Using ‘vi’ editor to add each Hyper-v loadable module:

Vi editor is old school stuff from the early days of Unix. I will just provide the required steps to use it for this purpose.

Start editing the ‘init’ file with the following command:

vi init

With the cursor keys move down to line 118 which should be just before the line ‘echo –n Detecting Android-x86…’. See the print screen:

permanent2

Now that you are on the line 118 do the following:

Press the [ESC] key to make sure you are on vi command mode.

Press the [o] key to add an additional line (like pressing the Return key on a normal text editor) and add the following text:

insmod hv_vmbus.ko
insmod hv_storvsc.ko
insmod hv_netvsc.ko
insmod hv_utils.ko
insmod hv_balloon.ko
insmod hid-hyperv.ko

Press the [ESC] key to exit from edit mode and go to command mode.

Type the following [:wq]     -> Just what’s between brackets []

 

Other useful Vi modes (should be enough to edit files):

[ESC] Vi command mode (also stops editing the file)
[i] Insert before cursor
[dd] delete current line
[:q] quit as long as there are not changes
[:q!] Force quit and discard changes
[:wq] or [:x] Write changes and quit

 

Vi full Cheat Sheet: http://www.lagmonster.org/docs/vi.html

7. Now we need to recreate the initrd image with all Hyper-v drivers included.

# find .| cpio -H newc -o -v | gzip -9 -c > ../mnt/android-4.4-RC2/initrd.img

 

8. Unmount the Virtual Hard disk partition

# umount ../mnt

 

9. Shutdown the VM through Hyper-V Manager

 

This completes the Part 1 of “How to install Android x86 4.4 RC2 on Hyper-V”. You can access the “Part 2: How to Install Android x86 4.4 RC2 on Hyper-V – Part 2: Configuration, Screen resolution and Network”.

R-Tape Loading error,
Luís Rato

 

How to install VyOS Router/Appliance as DNS Server



Hi there guys,

I have already covered on my last two posts how to install VyOS Router/Appliance on Hyper-V, see here:

How to install VyOS Router/Appliance on Hyper-V – Part 1: Setup and Install

How to install VyOS Router/Appliance on Hyper-V – Part 2: Configuration

 

I run my Lab’s on Hyper-V and VyOS is a fundamental piece to simulate real network environments. Sometimes I need to simulate a Public facing DNS Server and for that I will turn VyOS into my Public DNS Server.

You can’t do this by default on VyOS as the DNS Server packages are not available on the VyOS repository.

The following process will explain how to ground up a DNS Server on VyOS.

 

1. Install DNS Server packages on VyOS

We need to install the DNS Server packages (Bind9) from the Squeeze repository.

1.1. Adding Debian Squeeze repository to VyOS Sources List

Bind9 package is not available on VyOS source, so you’ll need to add the Debian Squeeze repository to the sources list (VyOS is based on Squeeze…).

# configure
# set system package repository squeeze components ‘main contrib non-free’
# set system package repository squeeze distribution ‘squeeze’
# set system package repository squeeze url ‘
http://mirrors.kernel.org/debian’
# commit
# save
# exit

You can validate the above configuration on the apt sources.list:

# sudo nano /etc/apt/sources.list

VyOS_Sources_list_thumb3

On the second line you can see the new apt repository (squeeze):

deb http://mirrors.kernel.org/debian stable main contrib non-free # squeeze #

To exit Press [CONTROL]+[X] Keys.

1.2 Update the packages list

To update the packages list from the new Squeeze Source make sure your Internet router (my router IP 192.168.1.1) is turned on so that from now on VyOS can access the Internet and update and download packages.

# sudo apt-get update

VyOS-apt-get

1.3 Install DNS Bind9 package:

# sudo apt-get install bind9 bind9-doc dnsutils

2. Chroot (jail) Bind9

It is not a good idea to run Bind9 as “root”, the following process explains how to chroot (jail) Bind9.

We will automate the whole process with a Shell script.

2.1 Create a Scripts folder and Shell script

Create a Scripts Folder and shell script named “chroot-bind9.sh” with the following:

# mkdir -p $HOME/scripts
# sudo nano $HOME/scripts/chroot-bind9.sh

Insert the following code to the Script and when finished type [CONTROL] + [X] keys to exit and save the file.

#!/bin/bash

sudo /etc/init.d/bind9 stop

sudo mkdir -p /var/chroot/bind9/{etc,dev,var/cache/bind,var/run/bind/run}
sudo chown -R bind:bind /var/chroot/bind9/var/*

sudo mknod /var/chroot/bind9/dev/null c 1 3
sudo mknod /var/chroot/bind9/dev/random c 1 8
sudo chmod 666 /var/chroot/bind9/dev/{null,random}

sudo mv /etc/bind /var/chroot/bind9/etc
sudo ln -s /var/chroot/bind9/etc/bind /etc/bind

sudo chown -R bind:bind /etc/bind/*
sudo chmod -R g+w /etc/bind/

sudo echo “\$AddUnixListenSocket /var/chroot/bind9/dev/log” > /etc/rsyslog.d/bind-chroot.conf

sudo sed -e ‘s,”-u bind”,”-u bind -t /var/chroot/bind9″,’ /etc/default/bind9 > /tmp/x && mv /tmp/x /etc/default/bind9

sudo /etc/init.d/bind9 start

 

2.2 Run the Shell Script to chroot Bind9

We need to make the script executable and run it with the following:

# cd $HOME/scripts
# sudo chmod u+x chroot-bind9.sh
# sudo ./chroot-bind9.sh

 

2.3 Fix “managed-keys.bind” file not found

If you check the syslog you will notice that there is an issue while loading the file “managed-keys.bind”, you can check the syslog with the following command:

# tail –f /var/log/messages

You will notice this entry:

managed-keys-zone ./IN: loading from master file managed-keys.bind failed: file not found

After confirming the failure on the syslog entries you can exit tail by pressing [CONTROL] + [C] keys.

 

To fix this first let’s announce the bind.keys location by editing “named.conf”.

# sudo nano /etc/bind/named.conf

Append to the last line the following entry:

include “/etc/bind/bind.keys”;

Here is a print screen with the output:

VyOS_Bind-keys

The file “managed-keys.bind” does not exist, we can create an empty one with touch and give the appropriate rights, for that do the following:

# sudo touch /etc/bind/managed-keys.bind
# sudo chown bind:bind /etc/bind/managed-keys.bind

 

3. Configuring DNS Zones files

Finally we can configure the DNS forward and reverse lookup zones and a DNS Forwarder.

I will create a forward lookup zone for the domain name “labdom.com”, a reverse lookup zone for the network segment “192.168.1.0/24” and a DNS Forwarder to my 3G ISP Router (192.168.1.1) so that the DNS Server can resolve public DNS names.

3.1 Create a DNS Configuration file

Go to the bind folder:

# cd /var/chroot/bind9/etc/bind

Create a backup of ”named.conf.local” to “named.conf.local_ORIGINAL”:

# sudo cp named.conf.local named.conf.local_ORIGINAL

3.2 Create a Forward Lookup zone file

Create the forward lookup file “labdom.com” from the default template file “db.local”:

# sudo cp db.local labdom.com

3.3 Create a Reverse lookup zone file

Create the reverse lookup file “labdom.com.loopback” from the default template file “db.127”:

# sudo cp db.127 labdom.com.loopback

3.4 Configure the DNS Zone configuration file “named.conf.local”

Now lets configure “name.conf.local”, for that start editing the file:

# sudo nano named.conf.local

Add the following entries to the “named.conf.local”, to configure the forward and reverse lookup zone and their location, at the end Press [CONTROL]+[X] Keys to Save the file and Exit:

#Public Zone
Zone “labdom.com” IN {
type master;
file “/etc/bind/labdom.com”;
allow-update {none;};
};

#Reverse zone
Zone “1.168.192.in-addr.arpa” IN {
type master;
file “/etc/bind/labdom.com.loopback”;
allow-update {none;};
};

3.5 Configure the DNS Forward lookup zone “labdom.com”

Edit the forward lookup zone file “labdom.com” with the following:

# sudo nano labdom.com

Add the following entries to the “labdom.com” and at the end Press [CONTROL]+[X] Keys to Save the file and Exit:

$TTL 604800
@ IN SOA labdom.com. root.labdom.com. (
2 ;Serial
604800 ;Refresh
86400 ;Retry
2419200 ;Expire
604800 ) ;Negative Cache TTL
;

@ IN NS labdom.com.
@ IN A 192.168.1.254
@ IN AAAA ::1
DA IN A 192.168.1.50

On the forward lookup “labdom.com” zone we added the “A” record for the host name “DA” with the IP 192.168.1.50.

The arrangement for the forward lookup file can be something like this:

VyOS_forward_lookup

 

3.6 Configure the DNS reverse loopback zone “1.168.192.in-addr.arpa

Edit the reverse lookup zone or loopback file “labdom.com.loopback” with the following:

# sudo nano /etc/bind/labdom.com.loopback

Add the following entries to the “labdom.com.loopback” and at the end Press [CONTROL]+[X] Keys to Save the file and Exit:

$TTL 604800
@ IN SOA labdom.com. root.labdom.com. (
1 ;serial
604800 ;refresh
86400 ;retry
2419200 ;expire
604800 ) ;negative cache TTL
;
@ IN NS labdom.com.
50 IN PTR DA.labdom.com.

On the loopback “labdom.com.loopback” zone we added the “PTR” record for “DA.labdom.com”.

The arrangement for loopback file can be something like this in the final output:

VyOS_reverse_lookup

 

3.7 Configure the DNS cd Forwarders for public name resolution

Edit the dns options file “named.conf.options” with the following:

# sudo nano named.conf.options

Add the following entries and press [CONTROL]+[X] to save and exit

forwarders {
192.168.1.1;
};

VyOS_DNS-forwarder

 

Restart the bind9 daemon:

# sudo /etc/init.d/bind9 restart

 

R-Tape Loading error,
Luís Rato

How to install VyOS Router/Appliance on Hyper-V – Part 2: Configuration



Completing the series with the Part 2 of “How to install VyOS Router/Appliance on Hyper-V” with the configuration process.

On my last Post “How to install VyOS router on Hyper-V – Part 1: Setup and Install” I’ve covered:

– Introduction: My LAB environment
– Phase 1: Download VyOS and prepare a VM to run VyOS router
– Phase 2: Install VyOS on a VM

On this post I’ll cover:

– Phase 3: Configure VyOS Router
– Phase 4: Configure VyOS Network Services

Phase 3: Configure VyOS Router

1. Make sure you Ejected the VyOS iso image from the VyOS VM

2. Start the VM

VyOS_login

3. Login to VyOS

VyOS login: vyos
VyOS password: password defined during the installation process

3. Confirm that you have valid NIC’s to be configure (eth0, eth1, eth2), list the NICs:

# show interfaces

4. Configure the router network interfaces, system gateway (ISP 3G router), system name server (ISP 3G router) and hostname.

# configure
# set interfaces ethernet eth0 address 10.0.0.254/24
# set interfaces ethernet eth1 address 192.168.1.254/24
# set interfaces ethernet eth2 address 172.0.0.254/24
# set system gateway-address 192.168.1.1
# set system name-server 192.168.1.1
# set system host-name vyos
# commit
# save

Note: Just to refresh your memory, when we created and configured the VyOS VM on Hyper-V we added the network interfaces in the following order: “Internal”, “External” and “Extranet – DMZ”. When you configure VyOS interfaces “eth0”, “eth1” and “eth2” the Ip Address and Netmask for those interfaces should respect the exact same order, for instance:

eth0 = 10.0.0.254/24 (“Internal” Virtual Switch)
eth1 = 192.168.1.254/24 (“External” Virtual Switch)
eth2 = 172.0.0.254/24 (“Extranet – DMZ” Virtual Switch)

If you fail to accomplish the configuration with the same order you’ll have a mismatch between your interfaces (eth0, eth1, eth2) and their designated vSwitch (“internal”, “external” and “extranet – DMZ”), obviously this can cause network issues.



5. Enable VyOS Web administration interface (not available at the moment with VyOS 1.0.3):

# set service https
# commit
# save

vyos_http

6. Enable VyOS SSH administration:

# set service ssh
# commit
# save

Phase 4: Configure VyOS Network Services

4.1 Configure NAT

4.1.1 Enable NAT Masquerade for the “Internal” vSwitch VLAN (10.0.0.0/24) through the eth1 interface connected to the “External” vSwitch

# set nat source rule 1
# set nat source rule 1 source address 10.0.0.0/24
# set nat source rule 1 outbound-interface eth1
# set nat source rule 1 translation address masquerade
# commit
# save
# exit

The VyOS interface eth1 on the “External” vSwitch is connected to my “3G ISP Wifi Router” as I am using Wireless Bridging on Hyper-V, while doing this NAT configuration I am providing Internet access to all the VM’s hosted on the 10.0.0.0/24 subnet and masking their Addresses, even on a “Internal only” Hyper-V Switch configuration. ;)

4.2 Configure webproxy for the network 172.0.0.x/24 (extranet – dmz)

set service webproxy default-port 8080
set service webproxy listen-address 172.0.0.254
set service webproxy disable-access-log
commit
save

4.3 Configure the name resolvers for VyOS

Edit the dns options file “resolv.conf” with the following:

# sudo nano /etc/resolv.conf

Add the following entries and press [CONTROL]+[X] to save and exit

nameserver 127.0.0.1
nameserver 192.168.1.1

With this dns resolvers configuration pointing to the localhost “127.0.0.1” VyOS will return DNS queries from it’s own DNS zones if you are running a DNS Server on VyOS (e.g. “labdom.com” and “1.168.192.in-addr.arpa”), and while also pointing to 3G ISP Router IP address 192.168.1.1 it will either resolve DNS queries on the Internet.

This completes the series of “How to install VyOS Router/Appliance on Hyper-V”.

R-Tape Loading error,
Luís Rato

How to install VyOS Router/Appliance on Hyper-V – Part 1: Setup and Install



Greetings everyone,

on today’s post I will walk you through the process of installing and configuring VyOS on Hyper-V, but first I need to talk about the predecessor Vyatta.

Vyatta was an Open Source software based on Linux for vRouter, Firewall, VPN and IPv4/IPv6 protocols, had a similar interface to JUNOS and Cisco IOS. On their portfolio there was Physical and Virtual Appliances but you were able to run it on your own HW with two flavors, Vyatta Subscription Edition and the Free version, both could have been installed on x86 hw or VM’s on Hyper-V, VMWare, Citrix XenServer, Open Source Xen and Virtualbox.

Simple statement: Vyatta Linux Open Source SW is a dead project after they became part of Brocade, see the whole history on wikipedia: http://en.wikipedia.org/wiki/Vyatta

Some people called this a catastrophe and the community mobilized for a forked version named VyOS, which has pretty much the same interface and functionality, it’s Open Source and Free.

I’ve used Vyatta on my Lab environments for a long time and already Blogged about it, so it was about time for a replacement with VyOS.

I will provide you the details about how to setup and configure VyOS router on Hyper-V with two separate posts.

On the first post “How to install VyOS Router/Appliance on Hyper-V – Part 1: Setup and Install” I will cover the following:

– Introduction: My LAB environment
– Phase 1: Download VyOS and prepare a VM to run VyOS router
– Phase 2: Install VyOS on a VM

On the second post “How to install VyOS Router/Appliance on Hyper-V – Part 2: Configuration” I will help you understand how to configure your network and provide some network services (NAT, DNS, Proxy).

– Phase 3: Configure VyOS Router
– Phase 4: Configure VyOS Network Services

 

Introduction: My LAB environment

Brief introduction of my lab environment:

– Running Windows 8.1 RTM Hyper-V Host;
– Running several Windows and Linux VM’s;
– VyOS router is:

  1. Running on a VM;
  2. Has 3 network interfaces;
  3. Configured for 3 network segments (internal, extranet – dmz, external);
  4. Provides NAT for Internal network, Proxy Server for Extranet network;

– VyOS Router configuration details:

Intranet interface: eht0
IP/mask: 10.0.0.254/24

External interface: eth1
IP/mask: 192.168.1.254/24

Extranet interface: eth2
IP/mask: 172.0.0.0/24

Default gateway: 192.168.1.1 (3G ISP Router IP Address)

NAT: Mask 10.0.0.0/24 through eth1

– Hyper-V Virtual Switch are configured as follow:

V-Switch 1: Name: “Internal” –> Internal Only
V-Switch 2: Name: “External” –> External –> Intel Wifi Ntwk Adapter –> Allow Mgmt OS to share the network adapter
V-Switch 3: Name: “Extranet – DMZ” –> Internal Only

Here is a print screen of the Hyper-V Virtual Switch configuration

hyper-v_virtual_switch

Here is a Visio Diagram of my Lab Setup:

VyOS

Phase 1: Download VyOS and prepare a VM to run VyOS router

1. Download Virtualization ISO: http://mirror.zenflow.net/vyos//iso/release/

e.g. for the version – “vyos-1.0.3-amd64.iso”:
Physical/virtual 64-bit ISO VyOS 1.0.3 (Hydrogen)
Size: 223MB



2. On Hyper-V Manager we will create 3 Virtual Switchs (“Internal Network”, “External Network” and “Extranet – DMZ”)

On the right-pane “Actions” menu click “Virtual Switch Manager

Select the Virtual Switch type “Internal” and click the button “Create Virtual Switch

Type the name “Internal” (or any other you prefer) and click “OK”

Click again on the “Virtual Switch Manager

Select the Virtual Switch type “External” and click the button “Create Virtual Switch

Type the name “External”, on the External Network option select your appropriate Network interface (LAN or WIFI), leave the rest with the defaults and click “OK

At last Click on the “Virtual Switch Manager

Select the Virtual Switch type “Internal” and click the button “Create Virtual Switch

Type the name “Extranet – DMZ” and click the button “Create Virtual Switch

3. On the Hyper-V Manager we will create the VyOS VM

On the right-pane Actions menu Click “New” –>Virtual Machine

On the New Virtual Machine Wizard –> Next

Define the Machine Machine Name “VyOS” and the desired location of the Virtual Machine configuration files

If your are running a Windows 8.1 or Windows Server 2012 R2 host Select the Virtual Machine “Generation 1

Set the Memory size “512” MB (should be enough, if you need intensive network usage consider more memory)

Select the “Intranet” Virtual Switch Network, we will add the other Network interfaces later

Create a Virtual Hard Disk (default: differential) with no more than “5GB” (depending on your needs, such as logging)

Select “Install Operating System from a Boot CD/DVD” and Select the VyOS “image file (ISO)”

Review the VM configuration ao click “Finish” to complete the VM creation

Right-click on the new VyOS VM and select “Settings

On the VyOS VM properties on the “Add Hardware” section select “Network adapter” and click “Add

Select the Virtual Switch “External“, keep the defaults and select “OK

Repeat the process and right-click on the new VyOS VM and select “Settings

On the VyOS VM properties on the “Add Hardware” section select “Network adapter” and click “Add

Select the Virtual Switch “Extranet – DMZ“, keep the defaults and select “OK”

You should end up with this configuration:

VyOS_vm_cfg

 

Phase 2: Install VyOS on a VM

1. Start the VM

VyOS_boot

2. Login to VyOS

VyOS login: vyos
VyOS password: vyos

3. Start the the VyOS image installation

Install image

4. Define the following installation settings:

Would you like to continue? Yes
Mirror Raid-1 (sda and sdb)? No
Partition (Auto/Parted/Skip): Auto
Install the image on? Sda
Continue? Yes
How big of a root partition should I create? 5368MB (your HDD full size)
What would you like to name this image? 1.0.3
Which one should I create to sda? /config/config.boot
Enter password for user ‘vyos’: define a new password
Which drive should GRUB modify the boot partition on? Sda

5. When finished validate your installation by running:

show version

Confirm the following details on the output:

Version: VyOS 1.0.3
Description: VyOS (hydrogen)
System type: x86 64-bit
Boot via: Livecd
(next boot without the Live CD it will show ‘image’)
Hypervisor: Microsoft HyperV
HW model: Virtual machine

6. Shutdown the VyOS Live installation process:

poweroff

7. Eject the CD from the VM to boot from the HDD next time

 

This completes the first part of “How to install VyOS Router/Appliance on Hyper-V” with the installation process. You can access the Part 2 for the configuration process on “How to install VyOS router on Hyper-V – Part 2: Configuration”.

R-Tape Loading error,
Luís Rato

How to migrate WordPress.com blog to WordPress hosted on Azure–Part 2



Greetings folks,

completing the series with “How to migrate WordPress.com blog to WordPress hosted on Azure – Part 2”, I will cover the following:

5.   Custom domain name for your Azure WordPress Blog (Optional)
6.   Configure WordPress.com redirection to Azure blog (Optional)
7.   Installing plugins for similar experience with WordPress.com (Optional but recommended)

You can access Part 1 here:  “How to migrate WordPress.com blog to WordPress hosted on Azure – Parte 1” for the following topics:

1.   Login or Subscribe Microsoft Azure
2.   Create WordPress blog on Microsoft Azure
3.   Configure Azure Web Hosting Plan for WordPress web site
4.   Migrate your blog content from WordPress.com to your WordPress blog hosted on Azure

5.   Custom domain name for your Azure WordPress Blog (Optional)

As we are moving a WordPress.com blog to a self-managed solution on Microsoft Azure, you probably want to turn it more personal with a custom domain name (http://www.yourdomain.com).

5.1 Create required DNS Records on your custom domain

You can use whatever domain register service you want, I usually go for Godaddy due to Office 365 integration and acceptable costs.

When you’ve created your WordPress blog on Microsoft Azure, you registered your new blog for free on “.azurewebsites.net” with a URL like this  “http://yourblog.azurewebsites.net”.

Assuming that you already have a registered domain (YOURDOMAIN.COM), if not register a new one, you need to create a “CNAME” record that will point your domain hostname (e.g. “WWW” to access your blog through “www.yourdomain.com”) to the Fully Qualified Domain Name (FQDN) of your blog hosted on Azure (“yourblog.azurewebsites.net”).

5.1.1 To perform this action, login with your Godaddy account, on the Top menu options select “Domain” and click on “Manage My Domains”.

godaddy_domain

5.1.2 On your Domains screen click on your Domain name to open it’s details.

godaddy_domain1

5.1.3 On your Domain details and action screen click on the “Add record” button.

godaddy_domain2

5.1.4 On the record type select “CNAME (Alias)”, on the Host field insert your desired host name (e.g. WWW) and on the Points to field insert the Fully Qualified Domain Name of your Azure Blog (yourblog.azurewebsites.net).

Click on the “Save” button to complete the action.

godaddy_domain3

5.2 Configure Azure Web site host headers with the new blog URL

Now that you have the required DNS records, you need to add the new URL address to Azure Blog web site host headers.

5.2.1 On your browser access to “https://manage.windowsazure.com” with your subscription account.


From the left pane click on “Web Sites” and click on your Web site name to jump into it’s details.

azure_website8

5.2.2 On your web site details click on “Configure

azure_hostheader

5.2.3 Scroll-down until you see the “domain names” section, click on “manage domains

azure_hostheader1

5.2.4 On Manage custom domains screen type your custom domain name “www.yourdomain.com”. As you already created the required CNAME record on your DNS Service you can proceed and click on the bottom-right checkmark button.

azure_hostheader2

 

5.3 Configure your custom domain URL on Azure WordPress Blog

To complete the process, you need to update your Azure WordPress Blog with your custom domain URL.

5.3.1 Login to your new Azure Blog on the left pane of your Dashboard screen clcik on “Settings” to open “General Setting”.

From there you need to fill the “WordPress Address (URL)” and “Site Address (URL)” with your custom domain address “http://your.domain.com” (same URL on both fields).

change URL2

 

6.   Configure WordPress.com redirection to Azure blog (Optional)

If you were running your WordPress.com blog for a while your Dashboard will show that part of your blog Page Views were coming from Search results or reference links from other Internet sources, such as Forums, blogs, Facebook, Twitter, etc.

6.1 Subscribe WordPress.com Site Redirect

If Page Views mean some sort of value to you, while migrating your blog to a hosting provider such as Azure, you should subscribe WordPress “Site Redirect” service. With that you can redirect the access of your previous WordPress.com blog to your new Blog on Azure.

This service has an affordable annual cost and is optional. To subscribe the service do the following:

6.1.1 Login to your WordPress.com blog with your account, on the Dashboard left pane click on “Store –> Store”.

wp_redirect

6.1.2 Scroll-down until you’ll find “Site Redirect” and click on “Buy now

wp_redirect1

6.1.3 On the next screen you will see that you are about to redirect your old blog “http://oldblog.wordpress.com” to your new blog address. Fill in your new blog address “http://www.yourdomain.com” and click on “Redirect to this URL

wp_redirect2

6.1.4 Complete the payment steps and you are done with the service subscription.


 

6.2 Configure Permanent Links format

When you use Site Redirection it is critical that you configure your Azure Blog with the same Permanent Links format that you had on your blog at WordPress.com. If you miss this step, you will manage to redirect your WordPress.com blog default page http://yourblog.wordpress.com/ to your Azure Blog default page  http://www.yourdomain.com/ but the redirection to all your Posts Links will fail.

Example of Blog Posts redirection failure:
Wordpress.com Permanent Links format:
http://yourblog.wordpress.com/?p=123

WordPress Azure Blog Permanent Links format:
http://www.yourdomain.com/2014/05/27/kali-linux-1-o-7-has-been-released/

Example of Blog post redirection success:
Wordpress.com Permanent Links format:
http://yourblog.wordpress.com/2014/05/27/kali-linux-1-o-7-has-been-released/

WordPress Azure Blog Permanent Links format:
http://www.yourdomain.com/2014/05/27/kali-linux-1-o-7-has-been-released/

You can use whatever format you want but just make sure that you have the same format on both sides.

6.2.1 Login to your Azure Blog and on the Dashboard left pane click on “Settings” and “Permalinks

azure_permanent_links

6.2.2 On Permanent Settings I will select “Day and name” which is the same format that I was using on my blog at WordPress.com

azure_permanent_links1

 

7.   Installing plugins for a similar experience to WordPress.com (Optional but recommended)

To keep your blog with a similar functionality like you had on WordPress.com you need to install some plugins. Depending on your requirements I am just sharing some Plugins that might interest you.

To add plugins to your site, login to your WordPress blog and access your Dashboard, on the Left pane click on “Plugins –> Add new”.

Must have:
Acunetix WP Security (Security Scanner for your blog)
Akismet (Antispam)
Jetpack by WordPress.com (Blog essentials – see below)

Additional (recommended):
Google AdSense (Implement Adsense on your site)
Google Adsense Dashboard (Adsense earnings on your dashboard)
ELI’s WordCents adSense Widget w Analytics (Sidebar Adsense Widget)
Click-Fraud Monitoring (Prevent your Ad account Ban/Sabotage)
Jetpack Sharing (Share content on social media)

 

Jetpack 3.0 by WordPress.com Category Alphabetical:

Beautiful Math
Use LaTeX markup language in posts and pages for complex equations and other geekery.

Carousel
Transform standard image galleries into full-screen slideshows.

Contact Form
Insert a contact form anywhere on your site.

Custom CSS
Customize your site’s CSS without modifying your theme.

Enhanced Distribution
Share your public posts and comments to search engines and other services.

Extra Sidebar Widgets
Add images, Twitter streams, your site’s RSS links, and more to your sidebar.

Google+ Profile
Give users the ability to share posts to Google+, and add your site link to your Google+ profile.

GGravatar Hovercards
Enable pop-up business cards over commenters’ Gravatars.

Infinite Scroll
Add support for infinite scroll to your theme.

Jetpack Comments
Let readers comment with WordPress.com, Twitter, Facebook, or Google+ accounts.

Jetpack Single Sign On
Allow your users to log in using their WordPress.com accounts.

JSON API
Allow applications to securely access your content through the cloud.

Likes
Give visitors an easy way to show their appreciation for your content.

Markdown
Write posts or pages in plain-text Markdown syntax.

Mobile Theme
Optimize your site with a mobile-friendly theme for tablets and phones.

Monitor
Receive notifications from Jetpack if your site goes offline — and when it it returns.

Notifications
Receive notification of site activity via the admin toolbar and your Mobile devices.

Omnisearch
Search your entire database from a single field in your Dashboard.

Photon
Accelerate your site by loading images from the WordPress.com CDN.

Post by Email
Publish posts by email, using any device and email client.

Publicize
Share new posts on social media networks automatically.

Related Posts
Display links to your related content under posts and pages.

Sharing
Allow visitors to share your content on Facebook, Twitter, and more with a click.

Shortcode Embeds
Embed content from YouTube, Vimeo, SlideShare, and more, no coding necessary.

Site Verification
Verify your site or domain with Google Webmaster Tools, Pinterest, and others.
NEW

Spelling and Grammar
Check your spelling, style, and grammar with the After the Deadline proofreading service.

Subscriptions
Allow users to subscribe to your posts and comments and receive notifications via email.

Tiled Galleries
Display your image galleries in a variety of sleek, graphic arrangements.

VVaultPress Paid
Protect your site with automatic backups and security scans. (Subscription required.)

VideoPress Paid
Upload and host video right on your site. (Subscription required.)

Widget Visibility
Specify which widgets appear on which pages of your site.

WordPress.com Stats
Monitor your stats with clear, concise reports and no additional load on your server.

WP.me Shortlinks
Enable WP.me-powered shortlinks for all posts and pages.

 

I’ve completed the series of “How to migrate WordPress.com blog to WordPress hosted on Azure”.

 

R-Tape Loading error,
Luís Rato

 
%d bloggers like this: