Internet Bandwidth

Sambit Bikas Pal sambitbikaspal at gmail.com
Sun Dec 5 14:10:31 UTC 2010


On Sun, Dec 5, 2010 at 07:56, Kaushal Shriyan <kaushalshriyan at gmail.com> wrote:
> Hi Sambit,
> Thanks for the quick reply. So what i understand is to enable iptables on my
> laptop or desktop to accomplish it.
> Please help me understand with some examples. Would appreciate if you can
> share me the iptables script.

Hi Kaushal,
It turns out slightly more complicated than I thought initially, but
nevertheless can be done.
You need two things- iptables and iproute2, both are there, by default
in ubuntu. Follow the instructions given below.

###########################################
#login as root
sudo su

#Create a new policy routing table for the non-default interface
echo 1 WIFI >> /etc/iproute2/rt_tables

#information about the non defualt interface

ip route add 192.168.1.0/24 dev wlan0 src 192.168.1.10 table WIFI
ip route add default via 192.168.1.1 dev wlan0 table WIFI

#Remember to change 192.168.1.0/24 with the subnet of your wifi
network, 192.168.1.10 with the address of your wlan0 interface
#Replace wlan0 with the name of your wifi interface
#Replace 192.168.1.1 with the gateway ip address


#Add routing rule, replacing 192.168.1.10 with the ip address of your
wifi interface

ip rule add from 192.168.1.10/32 table WIFI
ip rule add to 192.168.1.10/32 table WIFI

#check the rules

ip rule show

#Now executing the iptable script to mark packets

iptables -A PREROUTING -t mangle -i eth0 -p tcp --dport 6881:6999 -j
MARK --set-mark 1

#Bit torrent uses ports from 6881 to 6999, so iptables is marking
packets destined for those ports.

#Finally add a rule to send marked packets via the non defualt gateway

ip rule add from all fwmark 1 table WIFI

#######################################

Let me know if there is any confusion.

Hope it helps.


-- 
Sambit Bikas Pal
Dept of Physics,
Indian Institute Of Science Education & Research, Kolkata

Web:  http://www.botcyb.org
OpenPGP Key: http://keyserver.ubuntu.com:11371/pks/lookup?op=get&search=0x8E57F8B897D372B3




More information about the ubuntu-users mailing list