Can we create bandwidth limits for all users?
I want to share internet through my Ubuntu Server. Is this possible or not?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
Sharing Internet Connection is easy, and DpN has already provided a possible solution to that through a GUI. Alternatively, you can use
masquerading to achieve the same, though it'll be without a GUI. More information can be had on http://www.tldp.org/HOWTO/IP-Masquerade-HOWTO/firewall-examples.html
Following is a sample script that you can run on the server. You can provide the gateway of this server to other machines so that they can access internet through this.
#!/bin/bash echo -e "\n\nSETTING UP IPTABLES PROXY..." INTIF="eth0" EXTIF="eth1" EXTIP="your.static.IP.address" echo "Loading required stateful/NAT kernel modules..." /sbin/depmod -a /sbin/modprobe ip_tables /sbin/modprobe ip_conntrack /sbin/modprobe ip_conntrack_ftp /sbin/modprobe ip_conntrack_irc /sbin/modprobe iptable_nat /sbin/modprobe ip_nat_ftp /sbin/modprobe ip_nat_irc echo " Enabling IP forwarding..." echo "1" > /proc/sys/net/ipv4/ip_forward echo " Loading proxy server rules..." # Clearing any existing rules and setting default policy iptables -P INPUT ACCEPT iptables -F INPUT iptables -P OUTPUT ACCEPT iptables -F OUTPUT iptables -P FORWARD DROP iptables -F FORWARD iptables -t nat -F # FWD: Allow all connections OUT and only existing and related ones IN iptables -A FORWARD -i $EXTIF -o $INTIF -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A FORWARD -i $INTIF -o $EXTIF -j ACCEPT # Enabling SNAT (MASQUERADE) functionality on $EXTIF iptables -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE echo -e " Proxy server rule loading complete\n\n"
However, managing / limiting bandwidth (also called traffic shaping) is a different ball game. You would need to have some advanced knowledge of the tools to be used and what your needs would be. There are some external firwalls such as pfSense which help you manage it pretty well, but it'll require a different type of network setup.