Notes On OpenWRT
From Matt's Wiki
- Radvd needs the following patch applied to work in the buildroot (scanner.l) :
* https://packetprotector.org/trac/browser/buildroot/trunk/pp-openwrt-1.0/package/radvd/patches/no-libfl.patch?rev=1 old new 21 21 22 22 extern char *conf_file; 23 23 24 int yywrap(void) { return 1; } 25 24 26 int num_lines = 1; 25 27 %} 26 28
- It also needs the -lfl dependancy removed from its Makefile
- This is the radvd Makefile for package/radvd-np-Makefile
# # Copyright (C) 2006-2008 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. # include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=radvd-np PKG_RELEASE:=0.1 PKG_SOURCE_URL:=http://www.evolution-systems.co.uk/software/np PKG_VERSION:=0.1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz include $(INCLUDE_DIR)/package.mk define Package/radvd-np SECTION:=net CATEGORY:=Base system TITLE:=RADVD NP++ URL:=http://www.evolution-systems.co.uk endef define Package/radvd-np/description RADVD NP++ endef #CONFIGURE_ARGS += \ # --with-linux-headers="$(LINUX_DIR)" \ #define Build/Prepare #$(call Build/Prepare/Default) # ( cd $(PKG_BUILD_DIR) ; \ # [ -f ./configure ] || { \ # ln -sf configure.in configure.ac ; \ # autoconf ; \ # } \ # ) #endef #define Build/Compile # $(MAKE) -C $(PKG_BUILD_DIR) \ # CXX="$(TARGET_CROSS)gcc" #endef define Package/radvd-np/install $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) $(PKG_BUILD_DIR)/radvd $(1)/usr/sbin/ endef $(eval $(call BuildPackage,radvd-np))
- To add files to the buildroot create a directory named 'files' in the top level openwrt buildroot directory. Then inside there you can add any directory that would be in the root directory of the filesystem ('root', 'bin', 'etc') etc and add files into those. These will then be added to the final image after doing a 'make'. This is useful for adding mapd, the kernel modules etc to the image.
- Some configs
/etc/config/network
#### VLAN configuration config switch eth0 option vlan0 "0 1 2 3 5*" option vlan1 "4 5" #### Loopback configuration config interface loopback option ifname "lo" option proto static option ipaddr 127.0.0.1 option netmask 255.0.0.0 #### LAN configuration config interface lan # option type bridge option ifname "eth0.0" option proto static option ipaddr 192.168.30.1 option netmask 255.255.255.0 #### WAN configuration config interface wan option ifname "eth0.1" option proto static option ipaddr 10.30.150.10 option netmask 255.255.255.0 option gateway 10.30.150.1 option dns 10.30.0.20 option ip6addr 2001:630:80:7450::2/64 option ip6gw 2001:630:80:7450::1 config interface wifi option ifname lan0 option proto static option ipaddr 192.168.20.1 option netmask 255.255.255.0 option gateway 10.30.150.1 option dns 10.30.0.20 option ip6addr 2001:630:80:745b::1/64 option ip6gw 2001:630:80:7450::1
/etc/config/wireless
config wifi-device wlan0
option type mac80211
option channel 5
# REMOVE THIS LINE TO ENABLE WIFI:
option disabled 0
config wifi-iface
option device wlan0
option network wifi
option mode ap
option ssid NP_AP
option encryption none
#config wifi-device wlan1
# option type mac80211
# option channel 5
# REMOVE THIS LINE TO ENABLE WIFI:
# option disabled 1
#config wifi-iface
# option device wlan1
# option network lan
# option mode ap
# option ssid OpenWrt
# option encryption none
#config wifi-device wlan2
# option type mac80211
# option channel 5
#
# # REMOVE THIS LINE TO ENABLE WIFI:
# option disabled 1
#
#config wifi-iface
# option device wlan2
# option network lan
# option mode ap
# option ssid OpenWrt
# option encryption none/etc/config/dhcp
config dnsmasq
option domainneeded 1
option boguspriv 1
option filterwin2k '0' #enable for dial on demand
option localise_queries 1
option local '/lan/'
option domain 'lan'
option expandhosts 1
option nonegcache 0
option authoritative 1
option readethers 1
option leasefile '/tmp/dhcp.leases'
option resolvfile '/tmp/resolv.conf.auto'
#list server '/mycompany.local/1.2.3.4'
#option nonwildcard 0
#list interface br-lan
config dhcp lan
option interface lan
option start 100
option limit 150
option leasetime 12h
config dhcp wifi
option interface wifi
option start 100
option limit 150
option leasetime 12h
config dhcp wan
option interface wan
option ignore 1/etc/init.d/np_init
#!/bin/sh /etc/rc.common # NP++ startup script START=98 #STOP=15 start() { # Insert NP++ modules and launch radvd and mapad insmod /root/modules/np++-openwrt.ko insmod /root/modules/sample_map.ko sysctl -w net.ipv6.conf.all.forwarding=1 /usr/sbin/radvd -C /etc/radvd.conf # # Only need mapad if you are not an edge router # # /bin/mapad -C /etc/mapad-wlan0.conf & # /bin/mapad -C /etc/mapad-eth0.0.conf & } stop() { echo stopping NP++ rmmod sample_map rmmod np++-openwrt # killall -9 mapad # killall -9 radvd rm /var/run/radvd.pid # commands to kill application }
- Remember to run '/etc/init.d/np_init enable' to get the script to run at boot time (and to chmod +x it)
/etc/radvd.conf
interface wlan0 { AdvSendAdvert on; # # These settings cause advertisements to be sent every 3-10 seconds. This # range is good for 6to4 with a dynamic IPv4 address, but can be greatly # increased when not using 6to4 prefixes. # MinRtrAdvInterval 3; MaxRtrAdvInterval 10; # # You can use AdvDefaultPreference setting to advertise the preference of # the router for the purposes of default router determination. # NOTE: This feature is still being specified and is not widely supported! # AdvDefaultPreference low; # # Disable Mobile IPv6 support # AdvHomeAgentFlag off; # # Enable NP++ # EnNp on; # # example of a standard prefix ## prefix 2001:630:80:745a::/64 { AdvOnLink on; AdvAutonomous on; AdvRouterAddr on; }; # prefix 2001:db8::/64 # { # AdvOnLink on; # AdvAutonomous on; # AdvRouterAddr on; # }; # prefix 2001:db9:1:0::/64 # { # AdvOnLink on; # AdvAutonomous on; # AdvRouterAddr off; # }; # # NP++ Mappings - format: <mapping number>/<priority> # NpMapping 0/100 { AdvMapping on; }; NpMapping 1/1 { AdvMapping on; }; NpMapping 2/5 { AdvMapping on; }; NpMapping 3/10 { AdvMapping on; }; NpMapping 4/2 { AdvMapping on; }; }; interface eth0.0 { AdvSendAdvert on; MinRtrAdvInterval 3; MaxRtrAdvInterval 10; AdvDefaultPreference low; AdvHomeAgentFlag off; EnNp on; prefix 2001:630:80:745b::/64 { AdvOnLink on; AdvAutonomous on; AdvRouterAddr on; }; NpMapping 0/100 { AdvMapping on; }; NpMapping 1/1 { AdvMapping on; }; NpMapping 2/5 { AdvMapping on; }; NpMapping 3/10 { AdvMapping on; }; NpMapping 4/2 { AdvMapping on; }; };
hostapd.conf
driver=nl80211 interface=wlan0 bridge=br-lan ssid=OpenWrt hw_mode=g channel=6 wpa=1 wpa_passphrase=abcdefgh wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP CCMP
