Home Download Ubuntu

How to port forward utorrent client through ubuntu box

At home i have a ubuntu box which is having some services and it's doing internet connection sharing.
Uubuntu does not forward ports by default. utorrent is a small torrent client for windows and it needs a tcp port opened for you to have an active connection.
The difference between active and pasive connection is simple: if you are using a pasive connection (usually behind a firewall like a home router or a linux box) you can't connect to pasive peers. that means you are very limited.
To correct this, port forwarding is the solution. if you don't have a firewall installed on ubuntu box, this is the command:

sudo iptables -t nat -A PREROUTING -p tcp -i ppp0 --dport 17090 -j DNAT --to

- ppp0 is the internet interface, mine is a broadband connection. your's should be like eth0 or eth1.
- 17090 is the port you are forwarding
- is the ip and the port where your utorrent application resides.

Remember that this is not a permanent solution, after you restart your linux box, you will have to do this again. If you don't want to lose your settings you need to save iptables into a file and restore it after each startup.
to do this save iptables:

sudo iptables-save > iptables.rules

then edit /etc/network/interfaces:

sudo nano /etc/network/interfaces

and paste the following line after your internet network card:

post-up iptables-restore < /home/username/iptables.rules

where username is your username.

because i have a broadband connection, my file looks like this:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

auto dsl-provider
iface dsl-provider inet ppp
pre-up /sbin/ifconfig eth0 up # line maintained by pppoeconf
post-up iptables-restore < /home/username/iptables.rules #this file must exist
provider dsl-provider

You can test your port forwarding configuration.

Resources: cyberciti.biz, help.ubuntu.com


Post a Comment