Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello,
I'm having trouble controlling p2p usage [mostly BitTorrent] over my network - one of my flatmates, who has no concept of QoS or bandwidth limiting is torrenting all the time now. This is causing problems despite my all my traffic shaping. The problem is with one specific user - I'd rather not apply any restrictions to any other users at the moment. To fix the problem I'd like to block everything and allow only specific services [ssh, SSL, http, etc] on that IP. I tried this [adapted from another thread] on my own computer...
Code:
#!/bin/bash
iptables --flush
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A OUTPUT -p udp -o eth0 --dport 53 --sport 1024:65535 -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp -m multiport --dport 22,25,80,81,110,143,443,465,563,993,995,1863 -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp -m multiport --dport 53,6667,1080,8080 -j ACCEPT
iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
This works perfectly on my own computer! So now I'd like to add this script to my server with a specified IP and test it. Only trouble is, I've tried specifying my IP and it blocks all connectivity on my computer [obviously, I'd like to test this on my computer before applying it to anybody else].
This is what I tried
Code:
iptables -A INPUT -s 10.0.0.5 -j DROP
iptables -A FORWARD -s 10.0.0.5 -j DROP
iptables -A OUTPUT -s 10.0.0.5 -j DROP
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A OUTPUT -p udp -o eth0 --dport 53 --sport 1024:65535 -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp -m multiport --dport 22,25,80,81,110,143,443,465,563,993,995,1863 -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp -m multiport --dport 53,6667,1080,8080 -j ACCEPT
iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
I also tried moving the first 3 lines at the end and found they blocked nothing.
Could anyone give me some idea as to what I should try next.
2) what is your network topology? you can only affect traffic if it passes through your machine as a route or bridge. if it's all your desktops and an adsl router, then you're out of luck.
sorry, you've tried this on your own machine only? well when it's on a router, you'd use the FORWARD chain only and it should work fine to my (less than ideal iptables) knowledge.
Last edited by acid_kewpie; 04-02-2007 at 01:32 PM.
Well after trying that on my own IP I haven't had much luck - I can still torrent! Here is the first part of my network setup script.. [I won't post all of it because it is rather long]
Code:
#!/bin/bash
#init Network Setup Script
echo "Setup Initialized..."
echo "Flushing existing chains..."
# Delete and flush. Default table is "filter". Others like "nat" must be explicitly stated.
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
iptables -I FORWARD -i eth0 -s 10.0.0.76 -j REJECT
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A OUTPUT -p udp -o eth0 --dport 53 --sport 1024:65535 -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp -m multiport --dport 22,25,80,81,110,143,443,465,563,993,995,1863 -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp -m multiport --dport 53,6667,1100,6669,1080,8080 -j ACCEPT
iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
# Accept everything on loopback
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
echo "Setting up IP FORWARDing"
# Set up IP FORWARDing and Masquerading
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface eth1 -j ACCEPT
iptables --append FORWARD --in-interface eth2 -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.