OpenWrt

Openwrt je operacijski sistem osnovan na Linux jedru ter standardni knjižnici C musl. Uradna spletna stran projekta se nahaja na spletni strani openwrt.org.

Zadnja stabilna izdaja sistema je Chaos Calmer 15.05, izdana 2. septembra 2015. Prihaja tudi Designated Drive xx.yy. Sistem podpira več ali manj naprav.

Buildroot

Chaos Calmer

This version needs all the packages specified below for Barrier Breaker and in addition also libssl-dev.

cd ~
mkdir {dl-,}ChaosCalmer
cd ChaosCalmer
git clone git://git.openwrt.org/15.05/openwrt.git .
ln -s ../dl-ChaosCalmer dl
./scripts/feeds update -a
./scripts/feeds install -a
make defconfig
make prereq
make menuconfig

Barrier Breaker

Firstly, Debian 7 needs the following list of packages in order to successfully build image.

file g++ gawk gcc libncurses5-dev python2.7-minimal subversion unzip zlib1g-dev

Secondly, create directories, download the source and start configuring target system

cd ~
mkdir {dl-,}BarrierBreaker
cd BarrierBreaker
git clone git://git.openwrt.org/14.07/openwrt.git .
ln -s ../dl-BarrierBreaker dl
## Add individual package not present in openwrt repository
# ./scripts/feeds update -a
# ./scripts/feeds install olsrd
## Specify target platform
make defconfig
make prereq
make menuconfig

Finally, to build images, simply run make command. Built images (to be flashed to devices) will be located in bin/ directory.

Configuration

Buildroot needs some configuration; at least you should specify device CPU arhitecture.

TP-WR741
echo -e "CONFIG_TARGET_ar71xx=y\nCONFIG_TARGET_ar71xx_generic_TLWR741=y" > .config
Alix board
Target System: x86
Subtarget: PCEngines alix2
make MAKEOVERRIDES='' defconfig

Image Generator

Instead of building each Openwrt package (binary) from its source as it is done by Buildroot process, precompiled environments are available for each architecture, see Image Generator.

Download the Barrier Breaker's ImageBuilder for ar71xx.

cd ~
mkdir openwrt && cd openwrt
wget https://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/OpenWrt-ImageBuilder-ar71xx_generic-for-linux-x86_64.tar.bz2
tar -xjf OpenWrt-ImageBuilder-ar71xx_generic-for-linux-x86_64.tar.bz2
mv OpenWrt-ImageBuilder-ar71xx_generic-for-linux-x86_64 ImageBuilder-ar71xx
cd ImageBuilder-ar71xx

Examples of Image Generator

I have some configuration files that could be included into image on my Github.

TL-WR741
make image PROFILE=TLWR741 DEVICE_TYPE= PACKAGES="-wpad-mini -ip ip-full gre kmod-gre wpad iptables" FILES="files/"
TL-WR743

Hardware version: 2.1 and software version: 3.14.3 Build 130318 Rel.61337n works with Barrier Breaker (r42625).

make image PROFILE=TLWR743 DEVICE_TYPE= PACKAGES="iptables"
TL-WR703N

One with original build 130321 and firmware release 37153n works with Barrier Breaker (r42625)

make image PROFILE=TLWR703 DEVICE_TYPE= PACKAGES="iptables kmod-usb-serial-pl2303"

Installation to device

Usually consumer grade devices are equiped with some interface, eg. website, with system upgrade option.

CF card

If your CF card is accessible via /dev/sdc, run:

cd bin/x86/
gunzip openwrt-x86-alix2-combined-ext4.img.gz
dd if=openwrt-x86-alix2-combined-ext4.img of=/dev/sdc

Upgrade

Download new firmware image (.trx file) to ramdisk (into /tmp/ directory) and run sysupgrade -v /tmp/newfirmware.trx (mtd write /tmp/newfirmware.trx linux). Reboot.

Or if using x86 target, e.g. Alix, with CF card

gunzip openwrt-x86-alix2-combined-ext4.img.gz
sysupgrade -v -n /tmp/openwrt-x86-alix2-combined-ext4.img

Configuration

System

If you are using the ext2 filesystem on a CF card, you should limit write cycles by modifying /sbin/mount_root as follows.

mount -o remount,rw,noatime,nodiratime /dev/root /

This will slightly reduce the number of writting cycles.

Network

Wired IEEE 802.1X

If you need IEEE 802.1X wired authentication, install package wpa_supplicant and edit /etc/rc.local as:

date -s 201101200000
wpa_supplicant -Dwired -ieth2 -c/etc/wpa_supplicant.conf &
sleep 1
#udhcpc -i eth2 -q -A 3 &
ifconfig eth2 192.168.110.110 netmask 255.255.255.128
route add default gw 192.168.110.1
iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE
iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 22 -j DNAT --to 10.0.12.2:22

or in case of WRT54GL:

date -s 052000002010
wpa_supplicant -D roboswitch -i eth0.1 -p multicast_only=1 -c /etc/wpa_supplicant.conf &
sleep 3
udhcpc -i eth0.1 -q -A 3 &
#iptables -t nat -A POSTROUTING -o eth0.1 -j MASQUERADE

bridge
brctl addbr gbridge
brctl addif gbridge eth1
brctl addif gbridge eth2
ifconfig eth2 0.0.0.0
ifconfig eth1 0.0.0.0
ifconfig gbridge 10.82.4.1 netmask 255.255.255.224 broadcast 10.82.4.31 up
dnsmasq

/etc/dnsmasq.conf

dhcp-authoritative
dhcp-range=eth1,10.10.31.2,10.10.31.30,255.255.255.224,48h
dhcp-range=eth0,10.0.12.4,10.0.12.10,255.255.255.240,6h
dhcp-leasefile=/tmp/dhcp.leases
dhcp-option=eth1,3,10.10.31.1
dhcp-option=eth0,3,10.0.12.1
dhcp-option=eth1,6,193.2.1.66
dhcp-option=eth0,6,193.2.1.66
dhcp-host=00:00:00:4f:33:49,10.0.12.2,48h
dhcp-boot="/pxelinux.0",eser,10.82.4.13
local-ttl=1
addn-hosts=/jffs/hosts
server=/10.in-addr.arpa/10.82.4.14
server=/network.local/10.82.4.14
address=/local.debian.org/10.82.4.15

If you want to redirect all queries for domain integral.local to DNS server at 192.168.1.2, add second line to /etc/config/dhcp

list	'addnhosts'	'/etc/hosts2'
list	'server'	'/integral.local/192.168.1.2'
Uporaba:
dhcp-range=[net device],[start ip],[stop ip],[netmask],[lease time]
dhcp-option=[net device],3,[gateway ip]
dhcp-option=[net device],6,[dns server ip]

Troubleshooting

failsafe boot

Več na OpenWrt Failsafe

telnet 192.168.1.1
mount_root
passwd

Older stuff

AttitudeAdjustment

V okolju Debian 7 (wheezy) je potrebno naložiti pakete build-essential gawk git-core libncurses5-dev python subversion unzip zlib1g-dev.

mkdir AttitudeAdjustment
mkdir dl-AttitudeAdjustment
ln -s ../dl-AttitudeAdjustment AttitudeAdjustment/dl
cd AttitudeAdjustment
svn checkout svn://svn.openwrt.org/openwrt/branches/attitude_adjustment .
make defconfig
make prereq
make menuconfig
make

Backfire

V okolju Debian veje Lenny se potrebuje pakete: build-essential gawk libncurses5-dev python-minimal subversion unzip zlib1g-dev.

mkdir ~/backfire/
mkdir ~/dl-backfire/
cd ~/backfire/
ln -s ~/dl-backfire/ dl
svn checkout svn://svn.openwrt.org/openwrt/tags/backfire_10.03 .
make menuconfig
make