Category: Software

Configuring multiple static IP interfaces in Arch Linux (netcfg)

By , 2011-06-22 14:29

Being a long-time Ubuntu/Debian user, I’m used to editing the good ol’ /etc/network/interfaces file to configure network interfaces.

Recently, trying Arch Linux, I discovered that networking isn’t always that simple.

Most basic system parameters in Arch are configured in the /etc/rc.conf file. However, that file is limited to configuring one static wired ethernet connection.

In order to configure multiple interfaces, you need to install the netcfg package and create profiles for each NIC in /etc/network.d :

There are some examples provided, however none of them mention how to set a custom netmask or multiple DNS servers. So here are my two network profiles:

interface 1 (/etc/network.d/interface1-static)

CONNECTION='ethernet'
DESCRIPTION='Static IP WAN'
INTERFACE='eth0'
IP='static'
ADDR='172.32.24.108'
GATEWAY='172.32.24.1'
DNS=('172.16.24.1' '172.16.24.3')

interface 2

CONNECTION='ethernet'
DESCRIPTION='Static IP LAN'
INTERFACE='eth1'
IP='static'
ADDR='192.168.2.80'
NETMASK='255.255.254.0'

Once the profiles are created, go back to the /etc/rc.conf and make them activated at boot. The values for the NETWORKS array are the two files previously created in /etc/network.d:

# Enable these netcfg profiles at boot-up. These are useful if you happen to
# need more advanced network features than the simple network service
# supports, such as multiple network configurations (ie, laptop users)
#   - set to 'menu' to present a menu during boot-up (dialog package required)
#   - prefix an entry with a ! to disable it
#
# Network profiles are found in /etc/network.d
#
# This requires the netcfg package
#
NETWORKS=(interface1-static interface2-static)

# -----------------------------------------------------------------------
# DAEMONS
# -----------------------------------------------------------------------
#
# Daemons to start at boot-up (in this order)
#   - prefix a daemon with a ! to disable it
#   - prefix a daemon with a @ to start it up in the background
#
# If something other takes care of your hardware clock (ntpd, dual-boot...)
# you should disable 'hwclock' here.
#
DAEMONS=(hwclock syslog-ng net-profiles sshd netfs crond dbus @cups kdm)

Setting up rsync to mirror music library

By , 2011-04-06 21:04

Just threw together a quick rsync client-server setup for syncing my music library between to computers.

on one computer:

/etc/rsyncd.conf:

max connections = 2
log file = /var/log/rsync.log
timeout = 300

[music]
comment = Music Share
path = /path/to/music
read only = no
list = yes
uid = somebody
gid = somegroup
auth users = somebody
secrets file = /etc/rsyncd.secrets

On the client:

rsync --delete -azvv /path/to/local/music [email protected]::music

Also remember to check firewall settings, and run the rsync daemon as a user “somebody” that has access to write in the rsync’d folder.

And don’t forget to enable the rsync daemon in /etc/default/rsync

RSYNC_ENABLE=true

Copy files with progress

By , 2011-01-12 11:08
$ rsync -WavP src.file dst.file

Canadian french keyboard goes mobile!

By , 2010-12-16 23:17

After nearly a year of being slightly annoyed at my Nexus One’s stock keyboard having only an AZERTY French keyboard as opposed to a  QWERTY one we use in Canada, I finally took matters into my own hands and modded the recently “leaked” Gingerbread keyboard to make the French keyboard QWERTY. Download below.

Après près d’un an avec mon Nexus One et son clavier soit anglais, soit AZERTY, j’en ai eu assez et ai décidé de modifier le clavier Android pour permettre l’entrée du texte français via un clavier QWERTY. Téléchargement disponible ci-dessous.

gingerbreadkb-multilang-update-signed-fr_CA-qwerty.zip-signed.zip

References/This would not have been possible without:

  • Original idea: http://code.google.com/p/android/issues/detail?id=8494#c18
  • How to create a signed apk: http://www.androiddevelopment.org/tag/jarsigner/
  • How to create a signed update.zip: http://www.robmcghee.com/android/creating-an-android-update-zip-package/
  • Original Gingerbread keyboard with French dictionary: http://forum.xda-developers.com/showpost.php?p=9794752&postcount=109

Make Deluged allow other users to touch downloaded files

By , 2010-12-12 03:57

By default, deluged on Arch creates files as -rw-r–r–. I want -rw-rw-r– so that other non-daemon regular users have access to modify and delete the downloaded files. The fix is to add the non-deluge users to the “deluge” group (125), then add umask 002 to the “login” process of the daemon. So, in /etc/rc.d/deluged:

stat_busy "Starting Deluge Daemon"
[[ -z $PID ]] && su -l -s /bin/sh -c "umask 002 && /usr/bin/deluged >/dev/null" $DELUGE_USER

Redirecting a port to another host on same LAN using iptables

By , 2010-11-27 22:53

I have a strange situation where I want to redirect a specific port on one host to another host. That is, traffic to 192.168.1.100:8080 => 192.168.1.101:8080.

Found the answer on LQ forums.

iptables -A PREROUTING -t nat -p tcp -d 192.168.1.100 --dport 8080 -j DNAT --to-destination 192.168.1.101
iptables -A POSTROUTING -t nat -p tcp -d 192.168.1.101 --dport 8080 -j SNAT --to-source 192.168.1.100

Don’t ask me why this works. It just does. Well, the first line makes sense, but I have no idea what the second is doing.

After looking at the rule in Webmin, I think I figured it out.

  1. When a packet arrives at this computer, if protocol is TCP and destination is 192.168.1.100/32 (local IP) and destination port is 8080 then Destination NAT (change destination IP) to 192.168.1.101
  2. When a packet leaves this computer, if protocol is TCP and destination is 192.168.1.101/32 and destination port is 8080 (as would be the case for any packet modified by the above rule), then Source NAT (change source IP) to 192.168.1.100. (This ensures that the remote host .101 returns any packets via this computer, .100, rather than simply attempting to send them to the original requesting host.)

Update: This even works on an OpenVZ container! Just need to enable iptables nat in the vz config on the hardware node (VM host) [source].

nano /etc/vz/vz.conf

Then do Control W and SEARCH for IPTABLES

Comment out (by adding a # symbol to the line ) the current IPTABLES= line

and then copy/paste and add this line directly underneath the line you just commented out.

IPTABLES="ipt_REJECT ipt_recent ipt_owner ipt_REDIRECT ipt_tos ipt_TOS ipt_LOG ip_conntrack ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state iptable_nat ip_nat_ftp"

It is important to make sure this is all in 1 line and that it does not wrap.

Now Control-S and save – overwriting the current file.

Finally do an /etc/init.d/vz restart
to restart openVZ.

Crontab

By , 2010-11-10 12:13

A handy, colourful guide to configuring cron, the *nix task scheduler.

Stolen from: http://www.notesbit.com/index.php/scripts-unix/crontab-quick-complete-reference-setting-up-cronjobs-in-unix-and-linux/

Configuring PBXinaflash, my way

By , 2010-10-24 22:16

Setting up a PBXinaflash with a cheap Wildcard X100p card. A bit rough; for future reference.

Part 1: Initial setup and dahdi config

  1. Installed pbxinaflash (Bronze, Asterisk 1.6)
  2. set passwords using passwd-master script
  3. Enable ICMP ping in iptables.
  4. Run dahdi_genconf -v
  5. Run dahdi_cfg -v
  6. Add #include /etc/asterisk/dahdi-channels.conf
    to /etc/asterisk/chan_dahdi.conf
  7. At this point, asterisk should answer calls from the PSTN and play a “not in service” message.
  8. Next step is probably to edit /etc/asterisk/dahdi-channels.conf and set context to from-zaptel to be able to assign a DID using the FreePBX web GUI.

Part 2: Adding SIP trunk

  1. PEER Details:
    username=14165551212
    type=peer
    secret=s3cr3t
    host=voip.voipprovider.net
    dtmfmode=auto
  2. USER Details (not sure what’s necessary here, probably some of this shouldn’t be here)
    username=14165551212
    type=peer
    secret=s3cr3t
    qualify=no
    promiscredir=yes
    nat=yes
    language=en
    insecure=very
    host=voip.voipprovider.net
    fromuser=14165551212
    fromdomain=voip.voipprovider.net
    dtmfmode=auto
    disallow=h263&h263p
    context=from-trunk
    canreinvite=no
  3. In System Admin> Asterisk SIP settings page, change useragent and activate NAT/external IP options

Part 3: Fax Config

  1. Installed Fax Configuration module from “Module Admin”. Configure destination email.
  2. Installed Free Fax for asterisk using license obtained from Digium
  3. Add a “Misc destination” for System Fax to extension 666
  4. Enable Fax detection on inbound route. Set destination to Misc destination created in step 2
  5. Further reading: fax_for_asterisk_admin_manual, http://bestof.nerdvittles.com/applications/fax/ and http://nerdvittles.com/?p=237. Didn’t end up using the extension created by the script, but perhaps the rpms installed are necessary.
  6. Finally, Web fax for Asterisk : http://www.csrdu.org/nauman/2010/10/18/web-fax-for-asterisk/

Debian Squeeze installer for NSLU2

By , 2010-10-16 22:48

Just quickly threw together a flashable debian-installer image for NSLU2, following the guide from http://cyrius.com/debian/nslu2/repack.html.

Have NOT tested this yet, but technically it should work.

Tested, and works great! installing now. Hopefully it will be done by tomorrow morning.

During the install process, be sure to check off the “SSH Server” option! Otherwise you’ll have no way of accessing the slug.

new-nslu2.bin

Browser benchmarks

By , 2010-10-15 14:14

OK, so you still use Windows. That’s cool. It’s a fine OS, and there are some things it does that Linux and Mac just don’t.

But still using IE, now that’s crazy. It’s not standards-compliant (sure, Firefox isn’t either, but it’s close), it’s not customizable (except in the form of those ridiculous search toolbars), it’s not cross-platform (yeah yeah, you don’t need it to be because you only use Windows), it’s usually more vulnerable to attack and it’s just downright buggy.

If that’s not enough, here’s my final point: it’s SLOW. And to support this point, graphs! Everyone loves graphs, right?

Above graphs stolen from Ars Technica: Windows browsers benchmarked: October 2010 edition.

Custom theme by me. Based on Panorama by Themocracy