Monday 24 December 2012

Using the Draytek Vigor 2800V after Fibre Broadband (FTTC / VDSL)




The Draytek Vigor 2800V is a ADSL 2 / 2+ (Broadband) Router / Firewall with VPN / VoIP Server capabilities.  Currently you can get these second-hand for about £30-£40.  The Vigor 2800VG also has 802.11g wireless and are about £45-£55 second-hand.

So, you now have Fibre Broadband (FTTC/VDSL) and your old Draytek Vigor 2800V is just a Door stop. Well, at least it can be an expensive Printer Server right? You still want to use it for VoIP (Voice over IP)? Well, you cannot. Not as it stands anyway. Good old Draytek forced the default (World Wide) traffic to go out of the WAN (ADSL) port and no amount of messing about with routing in the Web Configuration Interface is going to solve that.

I found the solution!...

Here are the steps I took to get it working for VoIP. Offcourse, once you have forced a default route into the 2800V, it'll be useful for VPN, etc. again too. I am assuming that you were supplied with a new Router when you got Fibre Broadband.

  1. Make a note of your new Router's IP address. You need this to tell the Vigor 2800V where to route default (World Wide) traffic.

  2. If your old Vigor 2800V still has its old configuration, then you will need to reset it back to Factory Settings. Doing this will ensure that the following steps work and are not circumvented by some custom settings you may have. You can do this by inserting a Pencil into the small hole marked, 'Factory Reset', holding it for about 10 seconds, until, the ACT LED (Light) flashes erratically. Remove the Pencil and the Router will reboot, back to its original set up.

  3. Login into the Vigor 2800V Web Configuration Interface at 192.168.1.1 (Factory set IP address).

  4. Go into the Internet Access > PPPoE / PPPoA window. Disable the PPPoE / PPPoA Client. Click 'OK' and this will reboot your Vigor 2800V.

  5. Having logged back in, goto LAN > General Setup. Under For NAT Usage, set the 1st IP address. This will be the new IP address of the Vigor 2800V on your LAN. Remeber NOT to set it to the same IP address as any other device on your LAN, especially that used by your new Router.

  6. Disable IP Routing Usage. Disable DHCP Server. Assuming that you are using your new Router for DHCP and do NOT want a conflict.

  7. Now, add the IP address/es for the DNS Servers. Your ISP should have provide these. If not, do a Internet search for your ISP and DNS to find these. Otherwise, just enter the IP address of your new Router and hopefully it will resolve DNS fine for you.

  8. Click 'OK' and the Vigor 2800V will reboot itself.

  9. Log back in and at this point you could add your SIP account to VoIP > SIP Accounts but, it still will not work! One more step to fix this.

  10. You now need to Telnet into the Vigor 2800V CLI (Command Line Interface). You can do this in M$ Windows by bringing up a Cmd window or, in a Linux BASH or, my preference, using the PuTTY client application. Telnet your Vigor 2800V's IP address, port 23. If you have not yet set a password, just hit <ENTER>.

  11. Now type the following, ensuring that you put your new Router's IP address where indicated:-

    Code:
    ip route add 0.0.0.0 0.0.0.0 <New Router's IP address> IF0

    then press <ENTER>.

    Breaking this down, you are setting a default route of 0.0.0.0 with netmask of 0.0.0.0 via your new Router's IP address on the Vigor 2800V's LAN port (IF0).


    In my above example, .3 is my new Router that is connected to the BT FTTC VDSL NTE device.

  12. IF you have not done so in Step 9, set up your VoIP > SIP Accounts and you should now have VoIP again!

You can now also use the VPN Server too but, you will have to either open the required ports on your new Router or, set up as DMZ (demilitarized zone) Host on the new Router.

This solution works for my Vigor 2800V running 2.8.2 firmware.  My New Router is the Technicolor TG582n FTTC.



Sunday 2 December 2012

Merry Christmas e-card

Being so busy, I cannot be asked to write a Christmas Card list and then write out all those Christmas Cards so, here is a e-Christmas Card I made earlier...



ONN T816 PVR fails to start

Recently, the local mains electrical sub-station failed.  After the power cut and numerous brown-outs my ONN DTR160 PVR (Personal Video Recorder), based upon the Vestel T816, failed to start up.  The display just kept saying, 'Starting...'.

I removed the mains power and removed the cover.  I disconnected the 160Gb EIDE (Western Digital) Hard Drive from its power and IDE connectors.  I switch on the PVR and then shortly got TV channels and 'HDD failure' on the display.  If it had not started then in all likelyhood it would have been the Power Supply.

Finding that the HDD was the failure, I took it out and decided to hook it up to my Linux Kubuntu PC.  If you don't have Linux yourself,  there are Live Linux CD/DVD that you can download and burn to disk.  Booting from these, you have access to a range of tools that I have discussed before on this Blog.

I started GParted (Partition Editor) and selected the last device that was 160GB sized.  This showed two partitions, a small boot and a larger storage partition.  Both of ext2 filetype but the main partition had a Exclamation icon next to it, signifying that the partition was corrupt.  I could at this point have tried to repair the partition with other tools but, as I did not have any programs I wanted to keep, I decided to format the partition.  DO NOT format the smaller boot partition!

Replacing the HDD back into the PVR it started!  I went through the Installation Setup which, formatted the HDD again and I was left with a working PVR again.  :-)


Currently known variations include: Alba ALDTR160 (Argos) • Digihome DTR80 and DTR160 (Argos) • Hitachi HDR082, HDR162, HDR163 & HDR253 (Argos) • Logik LPVR168 (Currys/Dixons) • ONN DTR80 and DTR160 (Asda) • Sharp TU-R162H & TU-R252H • Wharfedale DTR160 HDMI and DTR250 HDMI (Argos) • Wharfedale LP160DTRHDMI and LP250DTRHDMI (Argos)


Thursday 29 November 2012

TIP: How do I type the copyright symbol ©?

Mac

Simply enter Option + G.


M$ Windows

Whilst Num Lock is on, hold down the ALT key, keep depressed and type on the Numeric keypad '0169'.

Linux

This works on (k)ubuntu at least, using a UK keyboard.

AltGr + Shift + C keys.


Addendum

The above Linux solution did not work in GIMP for me when I was trying to create a Watermark for my photos.  The solution was to do the above in something like Kate (text editor), highlight and copy it to the Clip board and then paste it into GIMP's text editor window.



Wednesday 28 November 2012

MySQL Correct character case of names

Sometimes a client will pass you some data with forenames, surnames or, both with people's names all in upper-case, lower-case or, a jumbled mess.  This looks a bit unprofessional when you are doing mail shots or e-mail mailings.

The below code shows how you can select the forename field, correcting the data's case.  It sets the first character to upper-case and the rest, lower-case.

Code:
SELECT CONCAT(UPPER(LEFT(forename, 1)), (SUBSTRING(LOWER(forename), 2))) As fname
FROM table1;


Alternatively, if you want to correct the data in the database table, you would...

Code:
UPDATE table1 SET forename =  CONCAT(UPPER(LEFT(forename, 1)), (SUBSTRING(LOWER(forename), 2)));


If the table contains a lot of data then, you may wish to run the UPDATE code over night, out of hours!



Monday 26 November 2012

Hello!

I've been Blogging for some years now, using phpBB2.  Mainly posting Hint 'n Tips on Technical stuff but, that old forum software (phpBB) is vulnerable to attack (XSS).

So, I am moving my old postings to here and I will blog my knowledge here from now on.

I will blog about:-
Amateur Radio - although I am taking a break from the hobby just now.

Computing -  in general, Linux, Ubuntu, M$ Windows, Postfix (Email server), MySQL (Database server).

Gran Canaria -  a beautiful Canary Island with its rich variety of micro climates and friendly locals.  A Photographers dream.  A lot of routes/treks for walkers.

Photography - My interest in Landscapes and Wildlife.

The picture  in the background is one of mine of Anfi Del Mar, Arguineguin, Gran Canaria where my wife and I have a time share.


Saturday 15 September 2012

linux BASH - replacing text in a file

If you want to replace some text within a file, that is too large to open in a GUI application then, this is when you fall back on the command line tools like sed.

But to make the change permanent, you have to add -i to the command:

Code:   
Syntax:
sed -i 's/<old_word>/<new_word>/g' <file>
sed 's/<old_word>/<new_word>/g' input.txt > output.txt

sed -i 's/Hello/hello/g' input.txt
   

Sed can also use regular expressions, so it's a very powerful tool.

The above searches for 'Hello' and replaces it with 'hello'.

Thanks to Eric_T for this which, I put here as a reminder to myself.

Code:   
#!/bin/bash
OLD="xyz"
NEW="abc"
DPATH="/home/you/foo/*.txt"
BPATH="/home/you/bakup/foo"
TFILE="/tmp/out.tmp.$$"
[ ! -d $BPATH ] && mkdir -p $BPATH || :
for f in $DPATH
do
  if [ -f $f -a -r $f ]; then
    /bin/cp -f $f $BPATH
   sed "s/$OLD/$NEW/g" "$f" > $TFILE && mv $TFILE "$f"
  else
   echo "Error: Cannot read $f"
  fi
done
/bin/rm $TFILE



A Note About Bash Escape Character
A non-quoted backslash \ is the Bash escape character. It preserves the literal value of the next character that follows, with the exception of newline. If a \newline pair appears, and the backslash itself is not quoted, the \newline is treated as a line continuation (that is, it is removed from the input stream and effectively ignored). This is useful when you would like to deal with UNIX paths. In this example, the sed command is used to replace UNIX path "/nfs/apache/logs/rawlogs/access.log" with "__DOMAIN_LOG_FILE__":

Code:   
#!/bin/bash
## Our path
_r1="/nfs/apache/logs/rawlogs/access.log"

## Escape path for sed using bash find and replace
_r1="${_r1//\//\\/}"

# replace __DOMAIN_LOG_FILE__ in our sample.awstats.conf
sed -e "s/__DOMAIN_LOG_FILE__/${_r1}/" /nfs/conf/awstats/sample.awstats.conf  > /nfs/apache/logs/awstats/awstats.conf

# call awstats
/usr/bin/awstats -c /nfs/apache/logs/awstats/awstats.conf


The $_r1 is escaped using bash find and replace parameter substitution syntax to replace each occurrence of / with \/.

Thanks to Vivek Gite
http://www.cyberciti.biz/faq/unix-linux-replace-string-words-in-many-files/

Very useful for replacing repetitive text string within a .csv file!

Wednesday 22 August 2012

Convert a Tab separated to Comma separated file

If you want to replace some text within a file, that is too large to open in a GUI application then, this is when you fall back on the command line tools.

Sometimes I get a Tab separated (.tsv/.txt) file and I need to convert it to a Comma separated (.csv) file before I can import it into a database table.

On a Linux server:
Code:   
tr -s '\t' <input | tr '\t' ',' >output
   
Substitute 'input' for the original filename and 'output' for the desired output filename.


Tuesday 14 August 2012

MySQL distinct count of data across multiple tables

You want to do a unique count of data across multiple tables.

Below is an example of getting a count of unique email addresses across two tables. Actually, I am looking for Females, aged 25 to 45 in the East Midlands, UK. I don't want duplicates because, I would not want to email the same person twice!

Code:   
SELECT COUNT(DISTINCT email) As East_Midlands
FROM (
SELECT email
FROM table_a
WHERE (gender = 'F' OR LOWER(title IN ('ms', 'miss', 'mrs')))
AND str_to_date(date, '%d/%m/%Y') BETWEEN '1967-01-01' AND '1987-08-13'
AND (SUBSTRING(postcode,1,2) IN ('CB','CO','DE','DN','IP','LE','LN','NG','NR','PE') OR postcode LIKE 'S[1-9]%')
UNION
SELECT email
FROM table_b
WHERE (gender = 'F' OR LOWER(title IN ('ms', 'miss', 'mrs')))
AND str_to_date(DOB, '%Y%m%d') BETWEEN '1967-01-01' AND '1987-08-13'
AND (SUBSTRING(postcode,1,2) IN ('CB','CO','DE','DN','IP','LE','LN','NG','NR','PE') OR postcode LIKE 'S[1-9]%')
) As SubQueryAlias;
   
I hope that makes sense. So, you have multiple selects, joined by the 'UNION', wrapped by the outer query which counts the distinct email addresses of the tables it embodies (as many as you want).

The 'As SubQueryAlias' at the end is needed to pull it together or, SQL will throw an error.



Monday 4 June 2012

Thwart attacks to your SFTP server with DenyHosts

For automated blocking of attackers try denyhosts. DenyHosts is a script intended to be run by Linux system administrators to help thwart SSH server attacks (also known as dictionary based attacks and brute force attacks).

http://www.cyberciti.biz/faq/block-ssh-attacks-with-denyhosts/


Saturday 24 March 2012

ClamAV 97.4 error while loading shared libraries

I installed ClamAV 0.97.4 on my Kubuntu system today, the installation went OK and no error were shown but when I tried to run virus scanning I got this error message:

Quote:   
clamscan: error while loading shared libraries: libclamav.so.6: cannot open shared object file: No such file or directory
   


A quick browse and found that the following fixed this:
Code:   
sudo ldconfig
   

Tuesday 6 March 2012

20 Linux System Monitoring Tools Every SysAdmin Should Know

Very good article on some essential monitoring tools.

http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html

iptables: Blocking attacking IP addresses

Excellent article on using iptables to block an attacking IP address.

http://www.cyberciti.biz/faq/linux-iptables-drop/

I needed to block a known russian SSH/SFTP hacker.

Code:   
iptables -A INPUT -s 91.205.189.27/255.255.255.255 -j DROP
   


Even better for automated blocking of attackers is denyhosts. DenyHosts is a script intended to be run by Linux system administrators to help thwart SSH server attacks (also known as dictionary based attacks and brute force attacks).

http://www.cyberciti.biz/faq/block-ssh-attacks-with-denyhosts/

Sunday 12 February 2012

Copy table between two Databases

Code:   
CREATE TABLE DB2.new_copy LIKE DB1.master_copy;
INSERT INTO DB2.new_copy SELECT * FROM DB1.master_copy;


The first line creates the table using the same engine as the existing table and creates the primary keys and/or indexes.
The second line copies the data across.

If the original table has many keys then it may help to speed the INSERT if you turn off the keys using the following before the INSERT:

Code:   
ALTER TABLE new_table_name DISABLE KEYS;
   
And then after the INSERT:

Code:   
ALTER TABLE new_table_name ENABLE KEYS;
   
These two statements are not supported by all MySQL Engine types though. InnoDB being one of them in MySQL ver 5.x



Linux: 20 Iptables Examples For New SysAdmins

Very good article on some essential iptables firewall rules.
http://www.cyberciti.biz/tips/linux-iptables-examples.html