Archive for category Tools

Connect to 3G networks in Uganda using the Linux command line

If you are a Linux user living in Uganda and use 3G internet, you may want to try out my tools to connect to the Internet. These are a couple of scripts I created a while back, however, I’ve now updated them to allow for the following:

  • You can now connect to Airtel, Orange/Africell, MTN, UTL, and Smart telecom.
  • I have added the capability to use your PC (or device such as a raspberry Pi) as a router, this way several devices can access the Internet using one 3g dongle. You can create a MiFI of sorts if you’re inclined to.
  • Query your modems for: EMEI, Serial, IMSI numbers, Lock status, Model/firmware version, etc.
  • A few BUG fixes and script clean ups.

Want to try it out? Visit my Github repository

Getting started with Docker on Linux

Docker containers are all the rage these days. However, if you’ve used Linux for a while you’ve come across LXC. For FreeBSDĀ users, docker containers will remind you of jails. Docker is essentially the same, but with a better tool chain that makes it easy to build system images and move them around different environments. Docker is also lightweight and very fast when compared to LXC for example.

With traditional office servers increasingly being moved to the cloud, it is easy to see why docker is popular. The ability to deploy and scale easily, makes docker a must-learn tool for IT administrators.

Here are a few notes to get you started with docker. For a detailed instructions, see the official docker user guide.

Getting started with docker

Install docker
yum install docker-io
(On Red Hat based systems)

Start the docker service
systemctl start docker

Pull docker image from the repository
docker pull fedora
(Ensure your Internet speed can handle the size of this image)

List all images available
docker images

Run docker image (interactive mode)
docker run -i -t fedora /bin/bash
(Type exit, to get out and leave container running)

Show containers current running
docker ps

To reconnect to the docker instance after exiting:
docker attach [CONTAINER ID]

To start an existing docker container:
docker start [CONTAINER ID]

To stop a docker container
docker stop

How to ship your first container
Reconnect to the container as shown above.

Show all the changes that were made since initial creation
docker diff [CONTAINER ID]

Commit your changes
docker commit [CONTAINER ID] [TAG]

Then to see the newly created image, run
docker images

You can now share your image. Please note that for the public docker repository, you need to follow the proper naming conventions when picking a tag for your image. Then push the image as follows:
docker push [USERNAME]/[TAG]

As you begin to create images using docker, you may want to read documentation on dockerfiles and how to use them to quickly deploy your containers.

How to setup a 3G Wireless Hotspot using Linux

The prevalent and most used type of Internet in Uganda currently is 3G via a USB modem or dongle. Have you found yourself somewhere; may be on travel, or at home, and you need to share your Internet connection with a friend or family members via WiFi? Do you wish you could just plug in your laptop, and just use your WiFi-enabled phone or tablet to surf? Are you a Linux user? Well its very easy to setup a WiFi hotspot for yourself using free and open source software.

hotspot_via_3g

There are several ways to do this, however, if you use Linux say on your laptop (or server), what you need is an application called hostapd. It is already installed in most Linux distributions like Redhat/Fedora, CentOS, Ubuntu, Debian, etc. If not simply install it as follows:

yum install hostapd (or use apt get for Debian based systems like Ubuntu)

Of course, you will need to have a Wireless device enabled on your laptop (or server box), and the chipset should support AP (Access Point) mode. To test this:

iw list (Look for modes section to see if AP mode is supported on your Wireless device

Also, you need to setup the Wireless interface device. In this post I am using an IP address of 172.16.0.1 for my Hotspot and ‘wlan0’ as the device name e.g.

ifconfig wlan0 172.16.0.1 Please remember that the above will not survive a reboot, so you need to permanently add it to your network configuration. On Redhat based systems:

vim /etc/sysconfig/network-scripts/ifcfg-wlan0Add these parameters:
TYPE=Wireless
BOOTPROTO=static
IPADDR0=172.16.0.1
NAME=”wlan0″
ONBOOT=yes

Now edit the configuration file for hostapd to suit your needs.

vim /etc/hostapd/hostapd.conf A typical hostapd.conf file looks like this:
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
wpa_passphrase=AVERYSECRETPASSPHRASE
interface=wlan1
ssid=MY-HOTSPOT
hw_mode=g
channel=6
driver=nl80211

The most important changes to make in the above file are:
ssid: The name you want your hotspot to be called
wpa: The encryption type. Use WPA2 and above always
wpa_passphrase: the password users will need to access your hotspot

After you have modified and saved the above file, enable hostapd services, so they also start during boot time.

systemctl enable hostapd.service or chkconfig hostapd on (old way)
systemctl start hostapd.service or service hostapd start (old way)

You will need some facility to dynamically offer IP addresses to clients of your hotspot. One very useful tool is called dnsmasq. Dnsmasq is a lighweight DHCP and DNS server. You can install it using your package manager e.g.

yum install dnsmasq Once installed, edit the configuration file for dnsmasq to suit your environment:

vim /etc/dnsmasq.confThe most important changes to make in the above file are:
interface=wlan0
domain=example.com
dhcp-range=172.16.0.10,172.16.0.199,12h
dhcp-option=3,172.16.0.1

Enable dnsmasq to start now and at boot time:

systemctl enable dnsmasq.service or chkconfig dnsmasq on (old way)
systemctl restart dnsmasq.service or service dnsmasq restart (old way)

The next step is to dial your ISP using either the GUI (NetworkManager) or the CLI tools like the ones I wrote about earlier. If you use the GUI tools, you will need to allow the laptop (server) to act as a gateway. This can be achieved simply:

/bin/echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE (NOTE: This assumes you are connected using a 3G modem with an assigned interface node of ppp0)

Once you are connected, and gateway has been setup, your clients should be able to connect to your Hotspot using the SSID and passphrase you setup above.

That’s it. Happy New year!

Digital TV in Uganda: Current Status

I’ve added a status page showing current OTA DVB-T channels broadcasting in Uganda.

You can access it at Digital TV Uganda.

Uganda’s digital TV migration is still in its testing phase and only the Kampala area is receiving these streams.