Aircrack suite + Ubuntu 11.10 problems with monitor mode channel

Recently I have been playing around with the aircrack suite and in particular the aireplay-ng tool. This tool may be used for ARP replay attacks, however it requires that the monitor mode interface is able to switch channels to the channel of the target device / access point. For some reason my monitor interface was stuck in channel -1. So to fix this I found a forum post on Ubuntu Forums which solves this problem: http://ubuntuforums.org/showpost.php?p=10550806&postcount=6

You can apply this to the wlan interface to put it directly into monitor mode and avoid using the airmon-ng tool altogether if you wish. You may also be able to apply this to the mon0 interface created by the airmon-ng tool as well, however I have not tried it yet.

The bulk of the problem is just the order in which monitor mode and channel are enabled, it must follow the order as follows:
ifconfig $IFACE down
iwconfig $IFACE mode managed
ifconfig $IFACE up
iwconfig $IFACE channel $@
ifconfig $IFACE down
iwconfig $IFACE mode monitor
ifconfig $IFACE up

Hope this solves some problems…