4th
MAR

Build your own dynamic DNS

Dynamic DNS, also known as DDNS

DDNS service lets you access your home computer (Router) for example ftp from anywhere in the world.

You do not need more such DynDNS providers, you can easily build a DynDNS server yourself.
This tutorial will  show the required steps to setup DynDNS on your Ubuntu or Debian machine with a static IP Address.

You should have the following:

  • A Linux server with root access
  • Access to the DNS server hosting your domain and the ability to customize the zone file yourself.

First of all create a subdomain for DNS-Server

A-Record:

dyndns   IN A       [IP-ADRESSE]
dyndns   IN NS      dyndns.myDomainName.

To make it easier to copy/paste commands, we define a few variables

DOMIN="myDomainName" 
ZONE="dyndns.$DOMIN" 

Generating a key-pair

dnssec-keygen -a hmac-sha256 -b 256 -n HOST $ZONE.
dyndns.euve8639.vserver.de. IN KEY 512 3 163 7S2K2LCtBZfXmucM80cmXghXxwUz1IBM7AyhWcPDJzE=

It creates two files.

One will be the server copy of the key file, and can contain multiple keys,
the other will be a single file named after the host that we’re going to be updating,
and needs to be moved to the host itself, for later use.
Now move the file $ZONE.key to the host which is going to be doing the updating and change the permissions on it.

-:~$ sudo chown root:bind /etc/bind/$ZONE.keys
-:~$ sudo chmod u=rw,g=r,o= /etc/bind/$ZONE.keys

Installing and configuring bind9

-:~$ sudo apt-get install bind9-host bind9utils dnsutils

Update the configuration file for bind “/etc/bind/named.conf.options“ and we should set the followings parameters:

– Allow Query to your dns from your private network (As the name suggests only the systems from your private network can query dns sever for name to ip translation and vice-versa)
– Allow recursive query
– Specify the DNS port ( 53)
– Forwarders (DNS query will be forwarded to the forwarders when your local DNS server is unable to resolve query)

-:~$ sudo vi /etc/bind/named.conf.options

options {
        directory "/var/cache/bind";
        forwarders { 8.8.8.8; };
        recursion yes;
        auth-nxdomain no; # conform to RFC1035
        listen-on port 53 { localhost; 192.168.0.0/24; };
        allow-query { localhost; 192.168.0.0/24; };
        //========================================================================
        // If BIND logs error messages about the root key being expired,
        // you will need to update your keys.  See https://www.isc.org/bind-keys
        //========================================================================
        dnssec-validation auto;
        auth-nxdomain no;    # conform to RFC1035
        //listen-on-v6 { any; };
};

Allow firewall 53 port for bind server

-:~$ sudo ufw allow 53

Update the configuration file ‘/etc/bind/named.conf.local’ to define the zone files for our zone as followed:

-:~$ sudo vi /etc/bind/named.conf.local

// DDNS keys
zone    "$DOMIN"   {
        type master;
        file    "/etc/bind/forward.$DOMIN";
 };

zone   "0.168.192.in-addr.arpa"        {
       type master;
       file    "/etc/bind/reverse.$DOMIN";
 };


--sed -i -e "s/\$DOMIN/$DOMIN/g" /etc/bind/named.conf.local

Validating Syntax of bind9 configuration and Zone files

-:~$ sudo named-checkconf /etc/bind/named.conf.local

Now create the forward lookup zone file. You can use the zone files (/etc/bind/db.local) and generate a copy of the file.

-:~$ sudo cp /etc/bind/db.local /etc/bind/forward.$DOMIN

-:~$ sudo vi /etc/bind/forward.$DOMIN

$TTL    604800

@       IN      SOA     $ZONE. root.$ZONE. (
                              6         ; Serial
                         604820         ; Refresh
                          86600         ; Retry
                        2419600         ; Expire
                         604600 )       ; Negative Cache TTL

;Name Server Information
@       IN      NS      $ZONE.

;IP address of Your Domain Name Server(DNS)
dyndns  IN       A      62.75.139.134

;Mail Server MX (Mail exchanger) Record
forgani.de. IN  MX  10  mail.$DOMIN.

;A Record for Host names
www     IN       A       62.75.139.134
mail    IN       A       62.75.139.134

;CNAME Record
ftp     IN      CNAME    www.$DOMIN.

Next we create a reverse lookup zone file at the same location,sample reverse lookup zone file is present at ‘/etc/bind‘ folder.

-:~$ sudo cp /etc/bind/db.127 reverse.$DOMIN
-:~$ sudo vi /etc/bind/reverse.$DOMIN

$TTL    604800
@       IN      SOA     $DOMIN. root.$DOMIN. (
                             21         ; Serial
                         604820         ; Refresh
                          864500        ; Retry
                        2419270         ; Expire
                         604880 )       ; Negative Cache TTL

;Your Name Server Info
@       IN      NS      dyndns.$DOMIN.
dyndns  IN      A       62.75.139.134

;Reverse Lookup for Your DNS Server
40      IN      PTR     dyndns.$DOMIN.

;PTR Record IP address to HostName
50      IN      PTR     www.$DOMIN.
60      IN      PTR     mail.$DOMIN.

Restart the BIND service for the changes

-:~$ sudo systemctl restart bind9
-:~$ sudo systemctl enable bind9

To cross verify the syntax your forward and reverse lookup zone files , use the command “named-checkzone“, example is shown below:

-:~$ sudo named-checkzone  /etc/bind/named.conf.local /etc/bind/forward.$DOMIN

Testing the DNS server with dig and nslookup

Use the dig command to find out DNS & its related information and verify the output shows that DNS is working
(dig is a part of dnsutils debian package)

:~$ dig $ZONE

check the reverse lookup query(PTR):

:~$ dig -x $IP-ADDRESS

Run ‘nslookup’ command against the DNS server to confirm the output of dig command

-:~$ nslookup $ZONE

Tests:

cat <<EOF | nsupdate -k /etc/bind/key.$CLIENT
server $HOST
zone $ZONE.
update delete $CLIENT.
update add $CLIENT. 60 A 10.10.10.10
update add $CLIENT. 60 TXT "Updated on $(date)"
send
EOF

Creating the empty Zone
The content of the zone file, depending on what exactly you’re trying to achieve.
This is created in /var/lib/bind/$ZONE

{
  echo '$ORIGIN .'
  echo '$TTL 300 ; 5 minutes'
  echo '$ZONE IN SOA $HOST. root@$DOMIN. ('
  echo '  1 ; serial (start at 1 for a dynamic zone instead of the usual date-based serial)'
  echo '  3600 ; refresh by secondaries (but they get NOTIFY-ed anyway)'
  echo '  600 ; retry (every 10 minutes if refresh fails)'
  echo '  604800 ; expire (slaves remove the record after 1 week if they could not refresh it)'
  echo '  300 ; minimum ttl for negative answers (5 minutes)'
  echo ')'
  echo 'NS $HOST.'
  echo '$ORIGIN $ZONE.'
} > /var/lib/bind/$ZONE

sed -i -e "s/\$HOST/$HOST/" -e "s/\$ZONE/$ZONE/g" -e "s/\$DOMIN/$DOMIN/g" /var/lib/bind/$ZONE service bind9 restart

Tests:

cat <<EOF | nsupdate -k /etc/bind/key.$CLIENT
server $HOST
zone $ZONE.
update delete $CLIENT.
update add $CLIENT. 60 A 10.10.10.10
update add $CLIENT. 60 TXT "Updated on $(date)"
send
EOF

Check the result:

#host -t ANY $HOST.$ZONE
host -t $CLIENT $HOST

4th
JUN

Check For Email pattern

check for email pattern

if( !preg_match( “/^(([^<>()[\]\\\\.,;:\s@\”]+(\.[^<>()[\]\\\\.,;:\s@\”]+)*)|(\”([^\”\\\\\r]|(\\\\[\w\W]))*\”))@((\[([0-9]{1,3}\.){3}[0-9]{1,3}\])|(([a-z\-0-9áàäçéèêñóòôöüæøå]+\.)+[a-z]{2,}))$/i”, $email ) ) {
$msg = ‘Email address was not recognized as a valid email pattern’;
}

get the mx host name

if( preg_match( “/@\[[\d.]*\]$/”, $email ) ) {
$mxHost[0] = preg_replace( “/[\w\W]*@\[([\d.]+)\]$/”, “$1”, $email );
$msg = ‘Email address contained IP address ‘.$mxHost[0].’ – no need for MX lookup’;
// get all mx servers – if no MX records, assume domain is MX (SMTP RFC)
$domain = preg_replace( “/^[\w\W]*@([^@]*)$/i”, “$1”, $email );
if( !getmxrr( $domain, $mxHost, $weightings ) ) { $mxHost[0] = $domain;
$msg = ‘Failed to obtain MX records, defaulting to ‘.$domain.’ as specified by SMTP protocol’;
}

28th
JUL

Clean up the Ubuntu

 

Install the Debian menu to make all installed applications

Missing Icons & Fix Broken Icons

sudo apt-get update
sudo apt-get install menu menu-xdg
update-menus

 

Keeping Ubuntu clean

Install deborphan with command:
sudo apt-get install deborphan

To delete unnecessary libraries just execute:
sudo deborphan | xargs sudo apt-get -y remove --purge

To delete unnecessary data


packages
use command:
sudo deborphan --guess-data | xargs sudo apt-get -y remove --purge

To see all


packages
which aren’t required by any others use command
deborphan --guess-all

There is another tool to delete orphaned

packages, it’s  GtkOrpha:
sudo apt-get install gtkorphan

Once it’s installed go to System –> Administration –> Remove Orphaned

Packages, enter your password and proceed with cleaning up.

Another nice tip is to clean partial and orphaned

packages by commands:
sudo apt-get autoclean
sudo apt-get autoremove

21st
MAY

increase the screen resolutions


Enter in root terminal:
$ sudo dpkg-reconfigure -phigh xserver-xorg

Select your video card by scroll up or down keys on your keyboard) and then hit enter.
the next select the resolutions that you would like to be available for Ubuntu by using the arrow keys to scroll up and down, and the Space Bar to select them.

Restart X by clicking Control+Alt+Delete (backspace). to set up new resolutions.

This starts the Xorg config process.

sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf_backup
sudo dpkg-reconfigure xserver-xorg
sudo xinit — :2

Look for errors:

tail -f /var/log/Xorg.0.log

Restart all servers by bouncing XDM (or gdm or kdm):

sudo /etc/init.d/xdm start

This starts a new X server — usually on tty8 or tty9 (CTRL-ALT-F8). You can go back to the original X server by pressing CTRL-ALT-F7.

9th
OCT

Java Tips

Convert Map to ArrayList:
Map hashmap = new HashMap () ;
hashmap.put ( “one”,new Integer (1) ) ;
hashmap.put ( “two”,null ) ;
hashmap.put ( “three”, new String (“THREE”) ) ;

aList = new ArrayList ( hashmap.values () ) ;

System.out.println ( “The size of HashMap = “+hashmap.size () ) ;
System.out.println ( “If hashmap empty = “+hashmap.isEmpty () ) ;
System.out.println ( “The value for the \”three\” key =”+hashmap.get (“three”) ) ;
hashmap.remove ( “two” ) ;

Set set= hashmap.keySet () ;
Iterator iter = set.iterator () ;
int i=1;
while ( iter.hasNext () ) {
System.out.println ( ” “+i+” ) “+hashmap.get ( iter.next () ) ) ;
i++;
}

OR:
for (Iterator iter = hashmap.keySet().iterator(); iter.hasNext();)
{
KeyType element = (KeyType) iter.next();
ValType value = (ValType)hashmap.get(element);
}

hashmap.clear () ;

Use for-each loop through Map entry set:
Map hashmap = new HashMap () ;
for ( Map.Entry pair : hashmap )
{
System.out.println ( pair.getKey () + ” :: ” + pair.getValue () ) ;
}

Use ArrayList:
ArrayList arraylist = new ArrayList () ;

arraylist.add ( “india”,””, new String(“three”),null,”new Integer (1) ” ) ;
arraylist.add ( new Float (3.5) ) ;
arraylist.add ( 1,dummy ) ;

Add array Elements to the arraylist:
String array [] = { “foo”,””,”tow”,null,”new Integer (1) ” } ;
for ( int i=0;i < array.length;i++ )
{
arraylist.add ( i,array [i] ) ;
}

for ( int i=0;i < arraylist.size () ;i++ )
{
System.out.println ( ” “+ ( i+1 ) +” ) “+arraylist.get ( i ) ) ;
}

System.out.println ( “The size of arraylist =”+arraylist.size () ) ;
System.out.println ( “The arraylist is Empty? =”+arraylist.isEmpty () ) ;

Set the element at position one:
arraylist.set ( 1,”J2EE Programmer” ) ;

Converts arraylist to array:
Object array [] = arraylist.toArray () ;

for ( int i=0;i < array.length;i++ )
{
System.out.println ( ” “+ ( i+1 ) +” ) “+ array [ i ] ) ;
}

String value = “FOO”;
if ( “FOO”.equals(value) ) {
// do something
}

substring in Java
returnString = (xmlString.substring(xmlString.indexOf(“<ns1:queryReference>”) + 20, xmlString.indexOf(“</ns1:queryReference>”)));

 

 

See more website here...

  • Advertise Here
  • Advertise Here
  • Advertise Here