2015年5月16日 星期六

Linux limiting download and upload traffic by using HTB

I use Ubuntu (14.04) 32 bit as an example

Kernel Customize Part

Get the kernel source by apt-get
apt-get source linux-image-$(uname -r)

Get the compile Dependence by
sudo apt-get build-dep linux-image-$(uname -r)

After download the source, use make menuconfig to enter the Kernel Configuration

Go to
Networking Support -> Networking options -> QoS and/or fair queueing

Enable: Incoming device classifiication(CONFIG_NET_CLS_IND)

Go to
Devices driver -> Network devices support
Enable: Intermediate Functional Block support (CONFIG_IFB)

Save and Make

QoS Part

tc (traffic control) is your best friend to config the QoS

# Handle both root and ingress traffic
tc qdisc add dev eth0 root handle 1: htb default 12
tc qdisc add dev eth0 handle ffff: ingress

# Mirred the traffic of eth0 ingress to ifb0 so that we can do traffic control
tc filter add dev eth0 parent ffff: protocol ip u32 match u32 0 0 action mirred egress redirect dev ifb0
tc qdisc add dev ifb0 root handle 1: htb default 12

# Some example of traffic controlling
tc class add dev eth0 parent 1: classid 1:10 htb rate 10mbit ceil 10mbit
tc class add dev ifb0 parent 1: classid 1:10 htb rate 10mbit ceil 10mbit

# Add filter to cature all traffic through the device
tc filter add dev eth0 parent 1: protocol ip u32 match u8 0 0 classid 1:10
tc filter add dev ifb0 parent 1: protocol ip u32 match u8 0 0 classid 1:10

2015年2月17日 星期二

Raspberry pi Access Point using rl8192cu with bridge interface

As the wifi signal in my room is some weak, I can't even watch youtube on my iPad. I decide to use Raspberry to extend the wifi from living room to my bed room.

Here is my device information
Devcie: Raspberry Pi B+
Wifi device: TL-WN823N (rl8192cu chipset)

In the very beginning, I am trying to use OpenWrt on Raspberry PI.

Target System: (Broadcom BCM2708/BCM2835)
Wireless Drivers: kmod-rt18192cu Realtek RTL8192CU/RT8188CU

The firmware can be compiled and run smoothly on the Raspberry. My HTC one can acess the wifi but my iPad mini 2 seems unavailable to use the wifi. The reason seems to be some driver compatibility which I need to take a lot of time to fix it. Therefore, I choose to flash the firmware back to Raspbian.


First, my network setting is something like that.

Internet ---- wifi router (192.168.100.0/24) ---- HomePlug ---- Raspberry pi(my room)

## Download the require package
sudo apt-get install iw bridge-utills hostapd

I want the wifi router to also take the role of DHCP and DNS. Therefore, I just want to bridge the wireless interface to my ethernet interface.

Edit the config
## In /etc/network/interfaces
auto lo

iface lo inet loopback

auto br-wan
iface br-wan inet dhcp
bridge-ports eth0 wlan0

## In /etc/init.d/hostapd

DAEMON_CONF=/etc/hostapd/hostapd.conf

Time to start the hostapd service
sudo service hostapd restart

There are some error throwing out which said 'nl80211 driver not found'

follow the guy which have modified a good hostapd version to use rtl8192cu chipset
http://blog.sip2serve.com/post/38010690418/raspberry-pi-access-point-using-rtl8192cu

Copy the binary to /usr/sbin/ to overwrite hostapd
## Edit the config /etc/hostapd/hostsapd.conf
## config
interface=wlan0
bridge=br-wan
hw_mode=g
ieee80211n=1
channel=6
ssid=your_ssid
wpa=3
wpa_passphrase=yourssidpw
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Finally:
sudo service hostapd restart

root@raspberrypi:/etc/init.d# service hostapd restart
[ ok ] Stopping advanced IEEE 802.11 management: hostapd.
[....] Starting advanced IEEE 802.11 management: hostapdioctl[RTL_IOCTL_HOSTAPD]: Invalid argument
. ok
root@raspberrypi:/etc/init.d#




2015年1月14日 星期三

My Ubuntu must install list

Install command development basic function
apt-get install vim build-essential screen terminator

Server type
sudo apt-get install openssh-server

Terminator
apt-get install terminator

Vim
apt-get install vim

build-essential
apt-get install build-essential

Ubuntu Tweak
http://ubuntu-tweak.com/

Synapse
apt-add-repository ppa:synapse-core/testing
apt-get update
apt-get install synapse