HowTo: Configure (K)torrent through a Router and Firewall protecting a Home Lan [Linux]
Summary: This Tutorial is about Ktorrent and geek networks, which are small home Lans set up by people who frequent computer forums. Home Lans are usually behind routers which contain a DHCP server and a firewall. The server (in the router) supplies an ip address to each of the workstations on the Lan. You have to tell the router which computer is going to use a torrent, i.e what that computer's IP address is. This is to allow communication between the computer and the torrent network on the internet. That often stumps new bees like me. I use Ktorrent but there's nothing special about that except that it's just great!
I had to work all this out by dithering around the Internet with Google. So here's a HowTo for people who are as new bees as me. Hope you save some time!
First up, there's nothing to it except perhaps getting through your firewall/s.
[This tutorial isn't for you if you have a home alone workstation with no router. But there's good firewall stuff in your openSUSE docs located at /usr/share/doc/packages/SuSEfirewall2/. If you have a workstation that uses a firewalled router (either directly or indirectly e.g. wifi, A/DSL modem), then read on]
You have to tell the router which computer is going to use a torrent, i.e what its IP address is. This is to allow communication through the firewall. So first up you have to change DHCP addressing for the computer that will use Ktorrent to Fixed IP addressing. Here are the steps:
Find out your IP address parameters
Open a command shell, change to superuser and enter ifconfig to get the current IP address of your network interface. Follow that command with command route, to get the IP address of your router. The session looks like this:
suzette@suse103:~> su Password: suse103:/home/suzette # ifconfig wlan0 Link encap:Ethernet HWaddr 00:17:9A:75:CA:A6 inet addr:192.168.2.27 Bcast:192.168.2.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:80934 errors:0 dropped:0 overruns:0 frame:0 TX packets:71661 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:65564496 (62.5 Mb) TX bytes:9501936 (9.0 Mb) Interrupt:21 Memory:dffe0000-dfff0000 suse103:/home/suzette # route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.2.0 * 255.255.255.0 U 0 0 0 wlan0 link-local * 255.255.0.0 U 0 0 0 wlan0 loopback * 255.0.0.0 U 0 0 0 lo default 192.168.2.1 0.0.0.0 UG 0 0 0 wlan0 suse103:/home/suzette #
I've marked the addresses in red. The IP address of your computer (actually the computer's network interface) is given in the first dialogue, in this example 192.168.2.27, and the address of the router is in the second part, in this example 192.168.2.1.
Change the computer that uses Ktorrent to Fixed IP addressing
You can do this for all computers on the Lan but you only need do it for those requiring port forwarding. Continuing with computer 192.168.2.27 as an example, open Yast and goto network devices --> network card. When you have the screen below, highlight the card as I have and edit it (click "configure").
You'll most likely see on the screen that opens that it has Automatic Address Setup (via DHCP). Move the dot to Static Address Setup and enter an IP address that isn't taken. Since you previously had address 192.168.2.27 assigned by the DHCP server, you could enter that. Or if you're a conscientious LAN administrtaor you might choose an address outside the address range being assigned by the DHCP server in the router (to minimise confusion with assigned addresses). I'll choose 192.168.2.100 as an example. Whatever you choose, if it's not the previously assigned address ...2.27, test that it's free by pinging the chosen address in a console.
I digress briefly to illustrate testing for a free IP address. If you get this as a test for 192.168.2.100, it's free:
Here's an example of pinging an address that's not free (In fact this one is my router):
OK, now I'm returning to changing the card's IP address in Yast: you should end up with a screen like the left hand screenshot below when you enter 192.168.2.100 in Yast's configurator.
When you set a fixed IP address, you also hand-code the gateway address in the router. Locate the "Routing" panel and enter the address of the gateway, as in the right hand screenshot above.
After you save and quit Yast, you'll probably need to reboot to re-set and test your internet connection. If you encounter difficulties check your network card configuration for a fixed IP address against the full settings in the Tutorial on configuring network interfaces.
Find out what port-forwarding Ktorrent needs
Open Ktorrent from the Kmenu with these clicks: Kmenu --> internet --> data exchange --> Ktorrent. Then click settings --> configure Ktorrent. You'll see this:
Note the alert labelled "Attention". Since you are behind a firewall you need to make a passage through it for Ktorrent. You use network address translation [NAT] for that. Ktorrent should show you which ports to forward to your computer. Here they are 6881 (tcp) and 4444 (udp).
Letting BitTorrent through the firewall in the router
You already know from the IP range you're using that the router is at the router is at 192.168.2.1 (or whatever you get/got). You can goto the router in your web browser and set it up. Enter 192.168.2.1 or whatever in the browser address bar, log in to the router and look for the tab that takes you to NAT routing. You'll get a screen like this where I have entered and marked settings appropriate for this example computer:
Of course, use whatever fixed IP address you have chosen instead of the one in my example. Note you enter the TCP (6881) and UDP (4444) ports that your computer tells you to in Ktorrent.
Life's good. have a good one
Cheers
Swerdna