2

I want to be able to set up two xen guests like this:

xen-create-image --hostname=xen1.example.com --size=10Gb --swap=512Mb --ip=192.168.0.101 --force --memory=256Mb --arch=i386 --debootstrap

and

xen-create-image --hostname=xen1.example.com --size=10Gb --swap=512Mb --ip=192.168.0.102 --force --memory=256Mb --arch=i386 --debootstrap

(the difference is the ips '192.168.0.102' and '192.168.0.101') I want to set it up so that '192.168.0.102' has dial-up speed and '192.168.0.101' has unshaped connection speed to xen1.example.com. I don't know anything about traffic shaping, or what i need to install to do this. So i guess when you answer be ultra noobie-concerned.

    #! /bin/bash
NETCARD=eth0
MAXBANDWIDTH=100000

# reinit
tc qdisc del dev $NETCARD root handle 1
tc qdisc add dev $NETCARD root handle 1: htb default 9999

# create the default class
tc class add dev $NETCARD parent 1:0 classid 1:9999 htb rate $(( $MAXBANDWIDTH ))kbit ceil $(( $MAXBANDWIDTH ))kbit burst 5k prio 9999

# control bandwidth per IP
declare -A ipctrl
# define list of IP and bandwidth (in kilo bits per seconds) below
ipctrl[192.168.1.1]="256"
ipctrl[192.168.1.2]="128"
ipctrl[192.168.1.3]="512"
ipctrl[192.168.1.4]="32"

mark=0
for ip in "${!ipctrl[@]}"
do
    mark=$(( mark + 1 ))
    bandwidth=${ipctrl[$ip]}

    # traffic shaping rule
    tc class add dev $NETCARD parent 1:0 classid 1:$mark htb rate $(( $bandwidth ))kbit ceil $(( $bandwidth ))kbit burst 5k prio $mark

    # netfilter packet marking rule
    iptables -t mangle -A INPUT -i $NETCARD -s $ip -j CONNMARK --set-mark $mark

    # filter that bind the two
    tc filter add dev $NETCARD parent 1:0 protocol ip prio $mark handle $mark fw flowid 1:$mark

    echo "IP $ip is attached to mark $mark and limited to $bandwidth kbps"
done

#propagate netfilter marks on connections
iptables -t mangle -A POSTROUTING -j CONNMARK --restore-mark

i did see this above, but i don't know what config file i need to edit.

So just to be clear. I want two ip's to access the same site, but one ip has dial-up speed and the other has untouched. Thanks so mcuh!

1 Answer 1

-2

I use my pfsense firewall for this..

ipfw and freebsd rocks for this type of thing over the Linux's

Hope you try this out :D

1
  • But this is not the question asked...
    – drumfire
    Feb 14, 2013 at 22:47

You must log in to answer this question.