msgbartop
A cronological documentation test project, nothing serious, really!
msgbarbottom

17 Aug 2009 Search Wikipedia using the command line

This post describes how you can search Wikipedia from the command line using a DNS tool like nslookup in Windows or dig in linux.
Handy if you don’t wan’t to open a Internet browser to do a simple Wikipedia query.

Windows
This is how it’s done in Windows

  1. Choose Start -> Run
  2. Write “cmd” and press OK
  3. Write “nslookup” and press ENTER
  4. Write “set type=txt” and press ENTER
  5. Write <topic>.wp.dg.cx and press ENTER

Using linux
This is how it’s done from a console window in linux

# dig +short txt search_keyword.wp.dg.cx

Example

# dig +short txt oslo.wp.dg.cx
"(formerly Christiania) is the capital and largest city in Norway. Metropolitan Oslo or the Greater Oslo Region makes up the third largest urban area in Scandinavia after Metropolitan Stockholm and Metropolitan Copenhagen. http://en.wikipedia.org/wiki/Oslo"

Source: http://lifehacker.com/5329014/search-wikipedia-from-the-command-line

Tags: , ,

Posted by

23 Jun 2009 HowTo use lftp as a sftp client

lftp is a file transfer program that allows sophisticated ftp, http and other connections to other hosts. If site is specified then lftp will connect to that site otherwise a connection has to be established with the open command.

Basic usage

  • lftp sftp://[domain name]
  • lftp sftp://example.com

Use a different user name than the one you are currently using

  • lftp sftp://[user name]@[domain name]
  • lftp sftp://username@example.com

Use a different port and different user name

  • lftp sftp://[user name]@[domain name]:[port number]
  • lftp sftp://userName@example.com:2222

Recursive download/upload

lftp> mirror directory_to_download
lftp> mirror -R directory_to_upload

For more lftp options type the following command in a console window

# man lftp

Tags: ,

Posted by

17 Jun 2009 Using DynDNS to access a server with dynamic IP-addresses

This post describes how you can access your server using a host name instead of the dynamic IP addresses (from DHCP) it has assigned at the moment. I’m going to describe how to use DynDNS, but this also applies to other services like EasyDNS, DSLreports.com and ZoneEdit. This tutorial has been tested on my Ubuntu 9.04 home server. You need to create an account at DynDNS if you are planning to to this.

First you have to install the ddclient package and in debian and Ubuntu you run the command

# aptitude install ddclient

To reconfigure ddclient

# dpkg-reconfigure ddclient

You should validate the config file /etc/ddclient.conf to make sure your settings are right.
This is the content of my config file

# Configuration file for ddclient generated by debconf
#
# /etc/ddclient.conf

pid=/var/run/ddclient.pid
protocol=dyndns2
use=if, if=eth2
server=members.dyndns.org
login=username
password='mysecretpassword'
hostname.dyndns.org

You can see that I user network interface eth2 as my internet connection and my login and password is the information I registered at DynDNS.com

Restart the ddclient daemon if you do any changes to the config file

# /etc/init.d/ddclient restart

You are now able to connect to your server using the hostname you defined in the server line in the config file, in my case hostname.dyndns.org

Tags: ,

Posted by

05 Jun 2009 Howto install Skype on a 64bit Ubuntu 9.04

This post describes how to install Skype, the popular VOIP and video conference program on a 64bit Ubuntu 9.04 (Jauty Jackalope) system.

# sudo apt-get install ia32-libs lib32asound2 libqt4-core libqt4-gui 
# wget -O skype-install.deb http://www.skype.com/go/getskype-linux-ubuntu
# sudo dpkg -i --force-architecture skype-install.deb

The application should now be located under Applications -> Internet -> Skype.

Tags: , , ,

Posted by

24 May 2009 ufw and IP masquerading

I’ve just upgraded my home server from Ubuntu 8.10 to 9.04 and experienced that my ufw firewall (iptables) would not route traffic from my local network to the Internet. My IP masquerading was not working anymore and since I had not documented the process when I set it up I had to search the Ubuntu pages to find the solution and came up with this.

The purpose of IP Masquerading is to allow machines with private, non-routable IP addresses on your network to access the Internet through the machine doing the masquerading. Traffic from your private network destined for the Internet must be manipulated for replies to be routable back to the machine that made the request. To do this, the kernel must modify the source IP address of each packet so that replies will be routed back to it, rather than to the private IP address that made the request, which is impossible over the Internet. Linux uses Connection Tracking (conntrack) to keep track of which connections belong to which machines and reroute each return packet accordingly. Traffic leaving your private network is thus “masqueraded” as having originated from your Ubuntu gateway machine. This process is referred to in Microsoft documentation as Internet Connection Sharing.

ufw Masquerading

IP Masquerading can be achieved using custom ufw rules. This is possible because the current back-end for ufw is iptables-restore with the rules files located in

/etc/ufw/*.rules

These files are a great place to add legacy iptables rules used without ufw, and rules that are more network gateway or bridge related.

The rules are split into two different files, rules that should be executed before ufw command line rules, and rules that are executed after ufw command line rules.

  • First, packet forwarding needs to be enabled in ufw. Two configuration files will need to be adjusted, in /etc/default/ufw change the
    DEFAULT_FORWARD_POLICY

    to “ACCEPT”:

    DEFAULT_FORWARD_POLICY="ACCEPT"

    Then edit /etc/ufw/sysctl.conf and uncomment:

    net.ipv4.ip_forward=1

    Similarly, for IPv6 forwarding uncomment:

    net.ipv6.conf.default.forwarding=1
  • Now we will add rules to the /etc/ufw/before.rules file. The default rules only configure the filter table, and to enable masquerading the nat table will need to be configured. Add the following to the top of the file just after the header comments:
    # nat Table rules
    *nat
    :POSTROUTING ACCEPT [0:0]
    
    # Forward traffic from eth1 through eth0.
    -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE
    
    # don't delete the 'COMMIT' line or these nat table rules won't be processed
    COMMIT

    The comments are not strictly necessary, but it is considered good practice to document your configuration. Also, when modifying any of the rules files in /etc/ufw, make sure these lines are the last line for each table modified:

    # don't delete the 'COMMIT' line or these rules won't be processed
    COMMIT

    For each Table a corresponding COMMIT statement is required. In these examples only the nat and filter tables are shown, but you can also add rules for the raw and mangle tables.

    [Note]
    In the above example replace eth0, eth1, and 192.168.0.0/24 with the appropriate interfaces and IP range for your network.
  • Finally, disable and re-enable ufw to apply the changes:
    sudo ufw disable && sudo ufw enable

IP Masquerading should now be enabled. You can also add any additional FORWARD rules to the /etc/ufw/before.rules. It is recommended that these additional rules be added to the ufw-before-forward chain.

Source: https://help.ubuntu.com/9.04/serverguide/C/firewall.html

Tags: , , , , ,

Posted by