Saturday, May 26, 2012

Change Network Interface Name

Changing network interface name is sometimes handy to do. I personally like to have my interfaces sorted out and have Ethernet as eth0, eth1 etc and wireless interfaces staring with wlan0. This makes running commands easier without having to think how my primary wireless interface was called on my machine. Defaults are eth0 and wlan0 for wired and wireless network interfaces and I like to keep them this way.

To determine your network interface names run
iwconfig

To change a network interface name you need to edit it in
/etc/udev/rules.d/70-persistent-net.rules~

so open it with gedit for example
sudo gedit /etc/udev/rules.d/70-persistent-net.rules~

The file is very short, easy to read and modify. You need to change the NAME tags to rename the interface. So for example if you currently have an eth1 interface that is actually your default wireless interface then you can look for NAME="eth1" and change it to NAME="wlan0".

Unfortunately changes take effect only after reboot in this case. 

Wednesday, May 23, 2012

New PirateBox Design

I am working on some web design for the new lighttpd version of the PirateBox. Html websites can be easily added and modified, but since PB is often run on OpenWRT routers -that are not too strong in terms of CPU power- no flash etc. is used.

I started looking at templates online to see if I could modify one of them to get what I needed. I found a template that more or less matches the style and minimal function requirements that I was looking for initially. Just a quick look at the start page at this stage:

This would be the start page where users get redirected after connecting to the PirateBox. Pages would open on the right hand side of the screen with maybe an exception to upload for which I want to have a separate window popping up. This would eliminate the need to wait until an upload finishes, the window could be left open in the background and you could still chat or browse the files. Not sure though, I will see what works best.

This is where I am at the moment. Not much, I am trying to get proper redirection for the sites and also experimenting with different visual effects, colours, logo types etc.

Tuesday, May 22, 2012

Installing PirateBox on TP-LINK MR3020

So finally my TPlink MR3020 portable router has arrived. OpenWRT can be put on it, its small and compact so perfect to run a PirateBox. For storage I've got a 32 GB Toshiba USB flash drive, plenty of storage capacity for the moment.
Compared to the process of installing PB on Ubuntu, installing this time went really easy without any problems or issues at all.


By following the PirateBox DIY OpenWrt I have managed to get my PB up and running in less than 30 minutes. The only issue I had was some Ethernet cable connection problem and some redirection, but all has been solved easily in a matter of minutes and my box is running right now.

Some tips

  • Make sure you know the basics of how to use the vi editor, you will HAVE to use it to perform basic file editing. In the DIY there is a link given to a "cheat sheet" that is quite handy. Basically you need the following:

    i  - Edit (now you can type, delete etc)
    dd  - Delete entire line
    ZZ  - Save changes if any and exit
    ESC  -Finish function (like edit mode)
  • The router should be in WISP mode while working on it, but obviously switch it back to AP when finished installing etc.
  • At step 10, you will be told to have a  etc/config/network like:
    config interface 'loopback'                                                               
            option ifname 'lo'                                                                
            option proto 'static'                                                             
            option ipaddr '127.0.0.1'                                                         
            option netmask '255.0.0.0'                                                        
                                                                                              
    config interface 'lan'                                                                    
            option ifname 'eth0'                                                              
            option type 'bridge'                                                              
            option proto 'static'                                                             
            option ipaddr '192.168.2.111'                                                       
            option netmask '255.255.255.0'                                                    
            option gateway '192.168.2.1'                                                     
            list dns '192.168.2.1'                                                           
            list dns '8.8.8.8' 
    However make sure to remove the last 2 lines (dns entries) else redirect/piratebox will not work properly.
  • Also make sure you remember the password you assign when you SSH into the router so you can change things 2 weeks later as well.
Apart from these minor things, installation should run smoothly.


I will start experimenting with my new PirateBox. Range test, how long will it run smoothly etc. Initially all I can say that within the proximity of the router, the download speed was 2.9-3.2 MB/s. Quite impressive.

Updating to Ubuntu 12.04

Upgrade:
It seems like I was right when giving myself time to upgrade to Ubuntu 12.04 LTS, especially since upgrade didn't go as smooth as expected.
Soon, during the installation an error was encountered that didn't go away later on either:
E: ubuntu-keyring: subprocess installed post-installation script returned error exit status 127
E: apt: dependency problems - leaving unconfigured

Also error messages are popping up like every 10 seconds, that is quite annoying...

Now the problem was with the aptdaemon meaning the software centre didn't work and neither did the update manager. I was sad when I saw posts about similar bugs and the solution was to run update-manager and reboot, my update manager didn't work at all.

I have tried the synaptic package manager
reinstall aptdaemon
remove & install aptdaemon
reinstall dpkg

Nothing worked so far.
Also the Dash Home is not really appearing properly even trying to set it to be "sensitive" still have to hoover 4-5 times with the mouse there to make it appear. (Common "bug" as I have read so far)

Long story short. I had so many errors in the system structure, without any update/reconfigure/restore functions working that I had to go for a full system reinstall.
I backed up my home folder and just reinstalled.


Reinstall:
If you are about to reinstall Ubuntu I suggest you read this very short guide that will save you a lot of hassle:
https://sites.google.com/site/easylinuxtipsproject/reinstallation

Basically what you need to do is:
  1. Boot from your USB/CD, run gparted and destroy your ubuntu and swap partitions. DO NOT FORMAT THEM
  2. Reboot your computer from your USB/CD and start installing Ubuntu and it will be automatically installed on the unallocated space.
(This is very helpful when you have multiple OS on your PC)




***
I am still having small issues with my newly installed system, like when plugging in or unplugging USB it freezes and there is one more system error that keeps popping up and wants to report itself for the 100th time, but it actually doesn't say what the problem is.

Thursday, May 3, 2012

Internet Track Blocker

I have started working on a script last week, but I have been busy so it took a while to finish it. Well not absolutely finish, but have it working properly.

The script is basically an "Internet track blocker" that can be used to block sites from collecting data on you. Sites like facebook for example.

Thanks to hak5.org and their awesome tips & tricks I became interested in this and took their initial idea one step further.


The command is in its simplest format looks like this:


sudo ngrep -q -d any 'facebook.com' -K 3

What is what?
  • -q -- tells ngrep to be quiet, though you will still see quite a lot of information floating around
  •  -d any -- ngrep should listen on all network interfaces
  • 'facebook.com' -- search for this term
  • -K 3 -- kill the data stream containing the word by sending 3 reset packets

The script 


Not being too creative, I have named my script "Block-d".
So basically what it does, it checks the data you send or receive and if it contains the given word (facebook in the above example), a reset segment will be sent, the connection reset and basically the data stream blocked.
So after freshening up my scripting knowledge and doing quite some research on the internet I have managed write a script that:
  • Is pre-set to block facebook and google (alone and together as well)
  • Allows to set what you want to block manually
  • Allows making a permanent blocklist with sites you want to block (useful if you have your specific sites you want to keep blocked, whatever you like)
  • You can set which interface you want to listen on (by default this is all=any
  • You can also tell how many reset segments you want to send (I've set it to 3, however 1 would do the job as well, its not bad to go for a little overkill)

What you will need to run this script

First of all you need ngrep. Now I don't remember if I installed it manually or it was pre-installed, but I think you will need to install it manually. Not hard at all,
sudo apt-get install ngrep

And of course you need the script as well that you can download from here:
Blockd.sh

Edit: Also available on Github at : https://github.com/Nargren/Blockd

After downloading the script, change the permissions to executable. You can simply right click/properties/permissions/Allow executing file as program. Or you can do it the terminal way
sudo chmox -x Blockd.sh

(I am about to set up a github account, but for now you can use the download link.)
I have tried to keep everything as simple as it is possible and I am open for any feedback. I have been running and testing it and seems to be working fine, although please contact me if you find any bugs or whatsoever. I'm also open for any ideas and suggestion how could it be made better.
(also, "use at own risk")

Please make sure you read the description at the start of the script, there is some important information there.

Screenshot