LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-28-2007, 04:14 PM   #1
vverheijen
LQ Newbie
 
Registered: Apr 2006
Location: ulicoten,Netherlands
Distribution: ubuntu,debian
Posts: 6

Rep: Reputation: 0
nat, bandwith throttling, and acces control


i have made this script. Will it work? or can it be better?


#/bin/sh
###download

tc qdisc add dev eth1 root handle 1: cbq avpkt 1000 bandwidth 1mbit

## ip 50
tc class add dev eth1 parent 1: classid 1:1 cbq rate 512kbit \
allot 1500 prio 5 bounded isolated

tc filter add dev eth1 parent 1: protocol ip prio 16 u32 \
match ip dst 192.168.123.50 flowid 1:1

## ip 51
tc class add dev eth1 parent 1: classid 1:2 cbq rate 512kbit \
allot 1500 prio 5 bounded isolated

tc filter add dev eth1 parent 1: protocol ip prio 16 u32 \
match ip dst 192.168.123.51 flowid 1:2

###### upload

tc qdisc add dev eth0 root handle 2: cbq avpkt 1000 bandwidth 512kbit

## ip 50
tc class add dev eth0 parent 2: classid 2:1 cbq rate 256kbit \
allot 1500 prio 5 bounded isolated

tc filter add dev eth0 parent 2: protocol ip prio 16 u32 \
match ip src 192.168.123.50 flowid 2:1

## ip 51
tc class add dev eth1 parent 2: classid 2:2 cbq rate 256kbit \
allot 1500 prio 5 bounded isolated

tc filter add dev eth1 parent 2: protocol ip prio 16 u32 \
match ip src 192.168.123.51 flowid 2:2

## nat
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 192.168.123.0/255.255.255.0 -o eth0 -j SNAT --to-source 10.0.0.6

## accept all packets from 50
iptables -A PREROUTING -s 192.168.123.50 -j ACCEPT
iptables -t mangle -A PREROUTING -s 192.168.123.50 -j RETURN

## accept all packets from 51
iptables -A PREROUTING -s 192.168.123.51 -j ACCEPT
iptables -t mangle -A PREROUTING -s 192.168.123.51 -j RETURN

## accept dhcp
iptables -A PREROUTING -s 0.0.0.0 -d 255.255.255.255 -sport 68 -dport 67 -p UDP -j ACCEPT
iptables -A PREROUTING -s 0.0.0.0 -d 255.255.255.255 -sport 68 -dport 67 -p UDP -j RETURN
iptables -A PREROUTING -s 192.168.123.1 -d 255.255.255.255 -sport 67 -dport 68 -p UDP -j ACCEPT
iptables -A PREROUTING -s 192.168.123.1 -d 255.255.255.255 -sport 67 -dport 68 -p UDP -j RETURN


## drop other packets
iptables -A PREROUTING -s -j DROP
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bandwith limitations, NAT and transparent proxy ilnli *BSD 1 02-20-2006 12:48 PM
bandwidth throttling z0mb1 Linux - Networking 4 11-27-2005 07:20 AM
bandwith control westverg Linux - Networking 4 01-18-2005 01:20 AM
What's the difference between Linux-NAT and Sygate-NAT? yuzuohong Linux - Networking 0 08-07-2002 04:07 AM
bandwith Control per ip address in linux jigs88 Linux - Networking 3 12-21-2001 01:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration