View previous topic :: View next topic |
Author |
Message |
ultraViolet Apprentice
Joined: 03 Apr 2004 Posts: 280 Location: Lyon, France
|
Posted: Thu May 05, 2005 11:45 am Post subject: Setting priority of packets on my local network |
|
|
Hi all !
I have a home network with 4 computers, and I am using a modem-router to connect to Internet with a DSL. Users are making a lot of different things, like using bittorrent or playing games. The matter is that when someone is using bittorrent, the ping is high and the gamers complains.
I have several questions :
- If I use my gentoo desktop as a router (amd64 3000+), will it takes a lot of computer load or slow down my own connection ?
- Will I be able to tell that the request from p2p are to be satisfied after the others one, and will the ping be more appropriate for online gaming ?
- Will I be able to share equally the global bandwith between the 1 to 4 computers using internet at a given moment ?
I know that some of these questions can be answered else where in the forums, but I guess there are different ways to all those things, and I don't really know what to search or where to begin. |
|
Back to top |
|
|
flakzeus Apprentice
Joined: 26 May 2004 Posts: 157
|
Posted: Thu May 05, 2005 3:13 pm Post subject: |
|
|
I use l7-filter (Application Layer Filtering) for this sort of thing. You can find it here http://l7-filter.sf.net _________________ "I'm not a super genius...or are I?" - Homer Simpson |
|
Back to top |
|
|
ultraViolet Apprentice
Joined: 03 Apr 2004 Posts: 280 Location: Lyon, France
|
Posted: Thu May 05, 2005 5:02 pm Post subject: |
|
|
Thank you very much, it seems to be exactely what I need.... I will try it right now. |
|
Back to top |
|
|
ultraViolet Apprentice
Joined: 03 Apr 2004 Posts: 280 Location: Lyon, France
|
Posted: Tue Aug 23, 2005 9:57 am Post subject: |
|
|
I am back from hollydays...
I couldn't manage to use the l7 filter. I finally choose the ipp2p filter, with these two scripts to start /stop the p2p :
To allow p2p
Code: |
/etc/init.d/iptables stop
# Constants
LOCALNET="192.168.1.0/255.255.255.0"
MARKPRIO1="1"
MARKPRIO2="2"
MARKPRIO3="3"
MARKPRIO4="4"
# Setting policy
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -P PREROUTING ACCEPT
#arp pas moyen
# Flushing all tables
iptables -F INPUT
iptables -F OUTPUT
iptables -F FORWARD
iptables -t nat -F POSTROUTING
iptables -t nat -F PREROUTING
iptables -t mangle -F OUTPUT
iptables -t mangle -F FORWARD
# Masquerading
iptables -t nat -A POSTROUTING -s $LOCALNET -j MASQUERADE
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -d 192.168.0.238 -j ACCEPT
#iptables -A FORWARD -m ipp2p --ipp2p --bit --apple --winmx --soul --ares -j DROP
# Setting priority marks
# Prio 1
# icmp
iptables -t mangle -A FORWARD -p icmp -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A OUTPUT -p icmp -j MARK --set-mark $MARKPRIO1
# ssh
iptables -t mangle -A FORWARD -p tcp --dport 22 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A OUTPUT -p tcp --dport 22 -j MARK --set-mark $MARKPRIO1
# non tcp
iptables -t mangle -A FORWARD -p ! tcp -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A OUTPUT -p ! tcp -j MARK --set-mark $MARKPRIO1
# Prio 3
# http
iptables -t mangle -A FORWARD -p tcp --dport 80 -j MARK --set-mark $MARKPRIO2
iptables -t mangle -A OUTPUT -p tcp --dport 80 -j MARK --set-mark $MARKPRIO2
# https
iptables -t mangle -A FORWARD -p tcp --dport 443 -j MARK --set-mark $MARKPRIO2
iptables -t mangle -A OUTPUT -p tcp --dport 443 -j MARK --set-mark $MARKPRIO2
# smtp
iptables -t mangle -A FORWARD -p tcp --dport 25 -j MARK --set-mark $MARKPRIO2
iptables -t mangle -A OUTPUT -p tcp --dport 25 -j MARK --set-mark $MARKPRIO2
# Remaining packets are marked according to TOS
iptables -t mangle -A FORWARD -p tcp -m tos --tos Minimize-Delay -m mark --mark 0 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A FORWARD -p tcp -m tos --tos Maximize-Throughput -m mark --mark 0 -j MARK --set-mark $MARKPRIO2
iptables -t mangle -A FORWARD -p tcp -m tos --tos Minimize-Cost -m mark --mark 0 -j MARK --set-mark $MARKPRIO4
# Enable kernel forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
/etc/init.d/iptables save
/etc/init.d/iptables start
|
To stop p2p :
Code: | /etc/init.d/iptables stop
# Constants
LOCALNET="192.168.1.0/255.255.255.0"
MARKPRIO1="1"
MARKPRIO2="2"
MARKPRIO3="3"
MARKPRIO4="4"
# Setting policy
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -P PREROUTING ACCEPT
#arp pas moyen
# Flushing all tables
iptables -F INPUT
iptables -F OUTPUT
iptables -F FORWARD
iptables -t nat -F POSTROUTING
iptables -t nat -F PREROUTING
iptables -t mangle -F OUTPUT
iptables -t mangle -F FORWARD
# Masquerading
iptables -t nat -A POSTROUTING -s $LOCALNET -j MASQUERADE
iptables -t mangle -A FORWARD -p tcp --dport 20510 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A OUTPUT -p tcp --dport 20510 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A FORWARD -p tcp --dport 20500 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A OUTPUT -p tcp --dport 20500 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A FORWARD -p tcp --dport 20600 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A OUTPUT -p tcp --dport 20600 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A FORWARD -p tcp --dport 20610 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A OUTPUT -p tcp --dport 20610 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A FORWARD -p tcp --dport 27950 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A OUTPUT -p tcp --dport 27950 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A FORWARD -p tcp --dport 27960 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A OUTPUT -p tcp --dport 27960 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A FORWARD -p tcp --dport 27965 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A OUTPUT -p tcp --dport 27965 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A FORWARD -p tcp --dport 27952 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A OUTPUT -p tcp --dport 27952 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A FORWARD -p tcp --dport 28960 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A OUTPUT -p tcp --dport 28960 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A FORWARD -p udp --dport 20510 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A OUTPUT -p udp --dport 20510 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A FORWARD -p udp --dport 20500 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A OUTPUT -p udp --dport 20500 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A FORWARD -p udp --dport 20600 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A OUTPUT -p udp --dport 20600 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A FORWARD -p udp --dport 20610 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A OUTPUT -p udp --dport 20610 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A FORWARD -p udp --dport 27950 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A OUTPUT -p udp --dport 27950 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A FORWARD -p udp --dport 27960 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A OUTPUT -p udp --dport 27960 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A FORWARD -p udp --dport 27965 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A OUTPUT -p udp --dport 27965 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A FORWARD -p udp --dport 27952 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A OUTPUT -p udp --dport 27952 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A FORWARD -p udp --dport 28960 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A OUTPUT -p udp --dport 28960 -j MARK --set-mark $MARKPRIO1
iptables -A FORWARD -m ipp2p --ipp2p --bit --apple --winmx --soul --ares -j DROP
# Remaining packets are marked according to TOS
iptables -t mangle -A FORWARD -p udp -m tos --tos Minimize-Delay -m mark --mark 0 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A FORWARD -p tcp -m tos --tos Maximize-Throughput -m mark --mark 0 -j MARK --set-mark $MARKPRIO2
iptables -t mangle -A FORWARD -p tcp -m tos --tos Minimize-Cost -m mark --mark 0 -j MARK --set-mark $MARKPRIO4
# Enable kernel forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
/etc/init.d/iptables save
/etc/init.d/iptables start
|
Hope it can help... |
|
Back to top |
|
|
|