From chaoswiki
Jump to navigation Jump to search

Openwrt knowledge


NVRAM is the EEPROM of the wrt54g. The Settings stored in the NVRAM is used by openwrt to configure the network interfaces and other settings like timezone and so on.

Info's about NVRAM settings


OLSR means Optimized Link State Routing protocol.

OLSR is a routing protocol for mobile ad-hoc networks. The protocol is pro-active, table driven and utilizes a technique called multipoint relaying for message flooding. You can configure multiple openwrt routers to talk to each other to find the best route from point A to point B.


WDS (Wireless Distribution System) can be used to mae a special tunnel between two openwrt's. It is also supported by many other Accesspoints. I didn't bring it to work so i had been looking for another solution. MESH networks soltuions can do that. OLSR is one implementation for that. AODV is another one.

Installing the software

Installing the openwrt firmware

I use this script to takeover the wrt54g. Get your firmware and copy it to the same directory as the takeover script.

Whether to use jffs2 or sqashfs is a philosophical question.

Plug in your wrt54g to you linux box. Configure your box in side (not!)

Code: Installing openwrt on the Linksys wrt54g
chmod +x takeover
cp openwrt-wrt54g-jffs2.bin  openwrt-g-code.bin

Wait about 5 minutes. If openwrt is booting the DMZ LED should lightning.

Code: Configure the network
nvram set lan_ifname=vlan0
nvram set lan_proto=static
nvram set lan_ipaddr=
nvram set lan_netmask=

nvram set wifi_ifname=eth1
nvram set wifi_proto=static
nvram set wifi_ipaddr=
nvram set wifi_netmask=

nvram set wan_ifname=vlan1
nvram set wan_proto=dhcp

nvram set wl0_mode=sta
nvram set wl0_infra=0
nvram set wl0_ssid=any-ssid
nvram set wl0_channel=1

nvram commit

Installing openvpn

Code: Installing openvpn
ipkg update
ipkg install openvpn
Code: /etc/init.d/S60openvpn
# load Bridging-Module
#modprobe bridge      
openvpn --mktun --dev tap0

# configure bridge
brctl addbr br1   
brctl stp   br1 off
brctl setfd br1 0  

brctl addif br1 vlan0
brctl addif br1 tap0 
ifconfig vlan0 promisc up
ifconfig tap0 promisc up 

ifconfig br1 netmask 0xffffff00 broadcast
echo 1 >  /proc/sys/net/ipv4/conf/br1/forwarding

openvpn --config /etc/openvpn/server.conf &

Code: /etc/openvpn/server.conf
port 1194
proto tcp-server
dev tap0
ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/server.crt
key /etc/openvpn/keys/server.key  # This file should be kept secret
dh /etc/openvpn/keys/dh1024.pem

#this will assign connecting clients address between the range of 10 and 50
#openwrt IP is

#this will allow for people to get the same IP address after a reconnect
ifconfig-pool-persist /etc/openvpn/ipp.txt

push "dhcp-option DNS"
keepalive 10 120
max-clients 10
Code: /etc/openvpn/server.conf
#the ip address of the openwrt box
proto tcp-client
dev tap


#to set /etc/resolv.conf if necessary
up /etc/openvpn/wlan/client.up
down /etc/openvpn/wlan/client.down

cert /etc/openvpn/wlan/keys/client1.crt
ca /etc/openvpn/wlan/keys/ca.crt
key /etc/openvpn/wlan/keys/client1.key

You now need to make the keys. You can use the easy-rsa script from the openvpn package. Get it from the homepage.

Installing olsrd

Code: Installing olsrd
ipkg install olsrd
Code: /etc/olsrd.conf
#The Network which the dhcp server is responsable for   
# Setting only on the box which has direct Internet Access
Interface "eth1"
# Hello interval in seconds(float)
HelloInterval 10.0
# HELLO validity time
HelloValidityTime 200.0
# TC interval in seconds(float)
TcInterval 25.0
# TC validity time
TcValidityTime 500.0
# MID interval in seconds(float)
MidInterval 25.0
# MID validity time
MidValidityTime 500.0
# HNA interval in seconds(float)
HnaInterval 25.0
# HNA validity time
HnaValidityTime 500.0       

Append a '&' to 'olsrd $OPTIONS' in /etc/init.d/olsrd so it look like:

       olsrd $OPTIONS &

Code: Starting olsrd
mv /etc/init.d/olsrd /etc/init.d/S60olsrd
/etc/init.d/S60olsrd start

Configuring dhcp

Code: Installing olsrd

Finish your configuration

Now you just need to setup your personal preferences like iptables shaper etc.

Good Luck, have fun!