Bittorrent Mainline Port Randomizer / Custom Settings script

Here is a quick and dirty bash script that I used when Bittorrent Mainline removed the random port option.

  • The script uses a random port to listen from a given range
  • Sets custom upload limits,refresh intervals and client address(IP)
  • Disables Linux uPnP
  • Changes the default data directory (default is ~/Desktop/Bittorrent)
  • Saves the downloaded file to current directory

Copy the code to text file and save it as and set execute permission with 'chmod a+x' and launch with ./ <torrentfile>.torrent

You may need to change the values to suit your needs. Also note that the You the /usr/bin/bittorrent-console is commandline client from the bittorrent Mainline for GNU/Linux and change the location on your Linux distro.

#set -n
# - a port randomizer for bittorrent mainline
#set -x 


while [ "$number" -le $MINPORT ]

  let "number %= $MAXPORT" 

exec /usr/bin/bittorrent-console  --ip  --display_interval 30 
--no_upnp --minport $number  --maxport 25000 --max_upload_rate 5120 
--max_initiate 70  --save_incomplete_in /mnt/BigMaMa/.bittorrent/incomplete
 --data_dir /mnt/bigMaMa/.bittorrent  --save_in . "$1"

Please feel free to improve the script !


  1. Thanks for sharing the link, but unfortunately it seems to be down... Does anybody have a mirror or another source? Please answer to my message if you do!

    I would appreciate if someone here at could repost it.


  2. @John,

    If you are using Ubuntu install the python-bittorrent package or use other clients like transmission.

  3. i just had an expeirence with utorrent and confirmed it with peer block. if they are reading your port for too long then they can disable internet connection. at least they can on the tether on my cell phone but changing random port about every 30 seconds they wernt able to do it and downloads went fine. it would be nice to have an option to randomize ports every 30 seconds and have time limit change option in thin randomizer.


You can leave a comment here using your Google account, OpenID or as an anonymous user.