From 56acf41bc9a18b40fbd8c1a3e4056a63c668b989 Mon Sep 17 00:00:00 2001 From: Rich Brown Date: Sat, 11 Apr 2015 20:49:42 -0400 Subject: [PATCH] Cloned from CeroWrtScripts --- LICENSE | 339 +++++++++++++++++++++++++++++++++++++++++++++ README.md | 194 ++++++++++++++++++++++++++ betterspeedtest.sh | 220 +++++++++++++++++++++++++++++ cerostats.sh | 77 ++++++++++ config-cerowrt.sh | 234 +++++++++++++++++++++++++++++++ netperfrunner.sh | 179 ++++++++++++++++++++++++ networkhammer.sh | 10 ++ tunnelbroker.sh | 137 ++++++++++++++++++ 8 files changed, 1390 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100755 betterspeedtest.sh create mode 100755 cerostats.sh create mode 100755 config-cerowrt.sh create mode 100755 netperfrunner.sh create mode 100644 networkhammer.sh create mode 100644 tunnelbroker.sh diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..22fbe5d --- /dev/null +++ b/LICENSE @@ -0,0 +1,339 @@ +GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..c1f0737 --- /dev/null +++ b/README.md @@ -0,0 +1,194 @@ +CeroWrtScripts +============== + +The CeroWrt router firmware project has largely eliminated the problem of *bufferbloat* on Ethernet for home routers. +This firmware makes a huge difference for wireless, too, although there's still more work to be done. +The symptoms of bufferbloat give people cause to complain, "the Internet feels slow today." +The techniques that the CeroWrt team have proved out are being widely adopted across +the Internet to make everyone's network performance better. + +This is a set of scripts (sometimes also called "Ceroscripts") that we use to measure (and improve) latency in home routers (and everywhere else!) +[http://bufferbloat.net/projects/cerowrt](http://bufferbloat.net/projects/cerowrt) +These scripts include: + +* Scripts that measure the performance of your router or offer load to the network for testing. + +* Script to configure the CeroWrt router consistently after flashing factory firmware. + +* Script to set up a IPv6 6-in-4 tunnel to TunnelBroker.net. + +* Script to collect troubleshooting information that helps us diagnose problems in the CeroWrt distribution. + +These scripts are bundled into CeroWrt 3.10.44-3 and newer as the 'cerowrtscripts' package, saved in the `/usr/lib/CeroWrtScripts` directory. +To get the newest versions, you can use `opkg update; opkg upgrade` + +If the scripts are not built into your version of CeroWrt, it is safe to put them in that CeroWrtScripts directory. + +--- +## betterspeedtest.sh + +This script emulates the web-based test performed by speedtest.net, but does it one better. While script performs a download and an upload to a server on the Internet, it simultaneously measures latency of pings to see whether the file transfers affect the responsiveness of your network. + +Here's why that's important: If the data transfers do increase the latency/lag much, then other network activity, such as voice or video chat, gaming, and general network activity will also work poorly. Gamers will see this as lagging out when someone else uses the network. Skype and FaceTime will see dropouts or freezes. Latency is bad, and good routers will not allow it to happen. + +The betterspeedtest.sh script measures latency during file transfers. To invoke it: + + sh betterspeedtest.sh [ -4 | -6 ] [ -H netperf-server ] [ -t duration ] [ -p host-to-ping ] [-n simultaneous-streams ] + +Options, if present, are: + +* -H | --host: DNS or Address of a netperf server (default - netperf.bufferbloat.net) +Alternate servers are netperf-east (east coast US), netperf-west (California), +and netperf-eu (Denmark) +* -4 | -6: Enable ipv4 or ipv6 testing (default - ipv4) +* -t | --time: Duration for how long each direction's test should run - (default - 60 seconds) +* -p | --ping: Host to ping to measure latency (default - gstatic.com) +* -n | --number: Number of simultaneous sessions (default - 5 sessions) + +The output shows separate (one-way) download and upload speed, along with a summary of latencies, including min, max, average, median, and 10th and 90th percentiles so you can get a sense of the distribution. The tool also displays the percent packet loss. The example below shows two measurements, bad and good. + +On the left is a test run without SQM. Note that the latency gets huge (greater than 5 seconds), meaning that network performance would be terrible for anyone else using the network. + +On the right is a test using SQM: the latency goes up a little (less than 23 msec under load), and network performance remains good. + + Example with NO SQM - BAD Example using SQM - GOOD + + root@cerowrt:/usr/lib/CeroWrtScripts# sh betterspeedtest.sh root@cerowrt:/usr/lib/CeroWrtScripts# sh betterspeedtest.sh + [date/time] Testing against netperf.bufferbloat.net (ipv4) [date/time] Testing against netperf.bufferbloat.net (ipv4) + with 5 simultaneous sessions while pinging gstatic.com with 5 simultaneous sessions while pinging gstatic.com + (60 seconds in each direction) (60 seconds in each direction) + + Download: 6.19 Mbps Download: 4.75 Mbps + Latency: (in msec, 58 pings, 0.00% packet loss) Latency: (in msec, 61 pings, 0.00% packet loss) + Min: 43.399 Min: 43.092 + 10pct: 156.092 10pct: 43.916 + Median: 230.921 Median: 46.400 + Avg: 248.849 Avg: 46.575 + 90pct: 354.738 90pct: 48.514 + Max: 385.507 Max: 56.150 + + Upload: 0.72 Mbps Upload: 0.61 Mbps + Latency: (in msec, 59 pings, 0.00% packet loss) Latency: (in msec, 53 pings, 0.00% packet loss) + Min: 43.699 Min: 43.394 + 10pct: 352.521 10pct: 44.202 + Median: 4208.574 Median: 50.061 + Avg: 3587.534 Avg: 50.486 + 90pct: 5163.901 90pct: 56.061 + Max: 5334.262 Max: 69.333 + +--- +## netperfrunner.sh + +This script runs several netperf commands simultaneously. +This mimics the stress test of [netperf-wrapper](https://github.com/tohojo/netperf-wrapper) [Github] but without the nice GUI result. + +When you start this script, it concurrently uploads and downloads several +streams (files) to a server on the Internet. This places a heavy load +on the bottleneck link of your network (probably your connection to the Internet), +and lets you measure both the total bandwidth and the latency of the link during the transfers. + +To invoke the script: + + sh netperfrunner.sh [ -4 | -6 ] [ -H netperf-server ] [ -t duration ] [ -p host-to-ping ] [-n simultaneous-streams ] + +Options, if present, are: + +* -H | --host: DNS or Address of a netperf server (default - netperf.bufferbloat.net) +Alternate servers are netperf-east (east coast US), netperf-west (California), +and netperf-eu (Denmark) +* -4 | -6: Enable ipv4 or ipv6 testing (default - ipv4) +* -t | --time: Duration for how long each direction's test should run - (default - 60 seconds) +* -p | --ping: Host to ping to measure latency (default - gstatic.com) +* -n | --number: Number of simultaneous sessions (default - 4 sessions) + +The output of the script looks like this: + + root@cerowrt:/usr/lib/CeroWrtScripts# sh netperfrunner.sh + [date/time] Testing netperf.bufferbloat.net (ipv4) with 4 streams down and up + while pinging gstatic.com. Takes about 60 seconds. + Download: 5.02 Mbps + Upload: 0.41 Mbps + Latency: (in msec, 61 pings, 15.00% packet loss) + Min: 44.494 + 10pct: 44.494 + Median: 66.438 + Avg: 68.559 + 90pct: 79.049 + Max: 140.421 + +**Note:** The download and upload speeds reported may be considerably lower than your line's rated speed. This is not a bug, nor is it a problem with your internet connection. That's because the acknowledge messages sent back to the sender consume a significant fraction of the link's capacity (as much as 25%). + +--- +## networkhammer.sh + +This script continually invokes the netperfrunner script to provide a heavy load. It runs forever - Ctl-C will interrupt it. + +--- +## config-cerowrt.sh + +This script updates the factory settings of CeroWrt to a known-good configuration. +If you frequently update your firmware, you can use this script to reconfigure +the router to a consistent state. +You should make a copy of this script, customize it to your needs, +then use the "To run this script" procedure (below). + +This script is designed to configure the settings after an initial "factory" firmware flash. +There are sections below to configure many aspects of your router. +All the sections are commented out. There are sections for: + +- Set up the ge00/WAN interface to connect to your provider +- Update the software packages +- Update the root password +- Set the time zone +- Enable SNMP for traffic monitoring and measurements +- Enable NetFlow export for traffic analysis +- Enable mDNS/ZeroConf on the ge00 (WAN) interface +- Change default IP addresses and subnets for interfaces +- Change default DNS names +- Set the SQM (Smart Queue Management) parameters +- Set the radio channels +- Set wireless SSID names +- Set the wireless security credentials + +**To run this script** + +Flash the router with factory firmware. Then ssh in and execute these statements. +You should do this over a wired connection because some of these changes +may reset the wireless network. + + ssh root@172.30.42.1 + cd /tmp + cat > config.sh + [paste in the contents of this file, then hit ^D] + sh config.sh + Presto! (You should reboot the router when this completes.) + +**Note:** If you use a secondary CeroWrt router, you can create another copy of this script, and use it to set different configuration parameters (perhaps different subnets, radio channels, SSIDs, enable mDNS, etc). + +--- +## tunnelbroker.sh + +This script configures CeroWrt to create an IPv6 tunnel. +It's an easy way to become familiar with IPv6 if your ISP doesn't offer native IPv6 capabilities. There are three steps: + +1. Go to the Hurricane Electric [TunnelBroker.net](http://www.tunnelbroker.net/) site to set up your free account. There are detailed instructions for setting up an account and an IPv6 tunnel at the + [CeroWrt IPv6 Tunnel page.](http://www.bufferbloat.net/projects/cerowrt/wiki/IPv6_Tunnel) +2. Edit the tunnelbroker.sh script, using the parameters supplied by Tunnelbroker.net. They're on the site's "Tunnel Details" page. Click on the "Example +Configurations" tab and select "OpenWRT Backfire 10.03.1". Use the info to fill in the corresponding lines of the script. +3. ssh into the CeroWrt router and execute this script with these steps. + + ssh root@172.30.42.1 + cd /tmp + cat > tunnel.sh + [paste in the contents of this file, then hit ^D] + sh tunnel.sh + [Restart your router. This seems to make a difference.] + +Presto! Your tunnel is up! Your computer should get a global IPv6 address, and should be able to communicate directly with IPv6 devices on the Internet. To test it, try: `ping6 ivp6.google.com` + +--- +## cerostats.sh + +This script collects a number of useful configuration settings and dynamic values for aid in diagnosing problems with CeroWrt. If you report a problem, it would be helpful to include the output of this script. + +By default, it collects information about the first 2.4GHz radio/interface, and writes the collected data to `/tmp/cerostats_output.txt` diff --git a/betterspeedtest.sh b/betterspeedtest.sh new file mode 100755 index 0000000..43b1fdd --- /dev/null +++ b/betterspeedtest.sh @@ -0,0 +1,220 @@ +#!/bin/sh + +# betterspeedtest.sh - Script to simulate http://speedtest.net +# Start pinging, then initiate a download, let it finish, then start an upload +# Output the measured transfer rates and the resulting ping latency +# It's better than 'speedtest.net' because it measures latency *while* measuring the speed. + +# Usage: sh betterspeedtest.sh [-4 -6] [ -H netperf-server ] [ -t duration ] [ -p host-to-ping ] [ -n simultaneous-streams ] + +# Options: If options are present: +# +# -H | --host: DNS or Address of a netperf server (default - netperf.bufferbloat.net) +# Alternate servers are netperf-east (east coast US), netperf-west (California), +# and netperf-eu (Denmark) +# -4 | -6: enable ipv4 or ipv6 testing (ipv4 is the default) +# -t | --time: Duration for how long each direction's test should run - (default - 60 seconds) +# -p | --ping: Host to ping to measure latency (default - gstatic.com) +# -n | --number: Number of simultaneous sessions (default - 5 sessions) + +# Copyright (c) 2014 - Rich Brown rich.brown@blueberryhillsoftware.com +# GPLv2 + +# Summarize the contents of the ping's output file to show min, avg, median, max, etc. +# input parameter ($1) file contains the output of the ping command + +summarize_pings() { + + # Process the ping times, and summarize the results + # grep to keep lines that have "time=", then sed to isolate the time stamps, and sort them + # awk builds an array of those values, and prints first & last (which are min, max) + # and computes average. + # If the number of samples is >= 10, also computes median, and 10th and 90th percentile readings + sed 's/^.*time=\([^ ]*\) ms/\1/' < $1 | grep -v "PING" | sort -n | \ + awk 'BEGIN {numdrops=0; numrows=0;} \ + { \ + if ( $0 ~ /timeout/ ) { \ + numdrops += 1; \ + } else { \ + numrows += 1; \ + arr[numrows]=$1; sum+=$1; \ + } \ + } \ + END { \ + pc10="-"; pc90="-"; med="-"; \ + if (numrows == 0) {numrows=1} \ + if (numrows>=10) \ + { ix=int(numrows/10); pc10=arr[ix]; ix=int(numrows*9/10);pc90=arr[ix]; \ + if (numrows%2==1) med=arr[(numrows+1)/2]; else med=(arr[numrows/2]); \ + }; \ + pktloss = numdrops/(numdrops+numrows) * 100; \ + printf(" Latency: (in msec, %d pings, %4.2f%% packet loss)\n Min: %4.3f \n 10pct: %4.3f \n Median: %4.3f \n Avg: %4.3f \n 90pct: %4.3f \n Max: %4.3f\n", numrows, pktloss, arr[1], pc10, med, sum/numrows, pc90, arr[numrows] )\ + }' +} + +# Print a line of dots as a progress indicator. + +print_dots() { + while : ; do + printf "." + sleep 1s + done +} + +# Stop the current print_dots() process + +kill_dots() { + # echo "Pings: $ping_pid Dots: $dots_pid" + kill -9 $dots_pid + wait $dots_pid 2>/dev/null + dots_pid=0 +} + +# Stop the current ping process + +kill_pings() { + # echo "Pings: $ping_pid Dots: $dots_pid" + kill -9 $ping_pid + wait $ping_pid 2>/dev/null + ping_pid=0 +} + +# Stop the current pings and dots, and exit +# ping command catches (and handles) first Ctrl-C, so you have to hit it again... +kill_pings_and_dots_and_exit() { + kill_dots + echo "\nStopped" + exit 1 +} + +# ------------ Measure speed and ping latency for one direction ---------------- +# +# Called with measure_direction "Download" $TESTHOST $TESTDUR $PINGHOST + +measure_direction() { + + # Create temp files + PINGFILE=`mktemp /tmp/measurepings.XXXXXX` || exit 1 + SPEEDFILE=`mktemp /tmp/netperfUL.XXXXXX` || exit 1 + + # Start dots + print_dots & + dots_pid=$! + # echo "Dots PID: $dots_pid" + + # Start Ping + if [ $TESTPROTO -eq "-4" ] + then + ping $4 > $PINGFILE & + else + ping6 $4 > $PINGFILE & + fi + ping_pid=$! + # echo "Ping PID: $ping_pid" + + # Start netperf with the proper direction + if [ $1 = "Download" ]; then + dir="TCP_MAERTS" + else + dir="TCP_STREAM" + fi + + # Start $MAXSESSIONS datastreams between netperf client and the netperf server + # netperf writes the sole output value (in Mbps) to stdout when completed + for i in $( seq $MAXSESSIONS ) + do + netperf $TESTPROTO -H $TESTHOST -t $dir -l $TESTDUR -v 0 -P 0 >> $SPEEDFILE & + #echo "Starting $!" + done + + # Wait until each of the background netperf processes completes + # echo "Process is $$" + # echo `pgrep -P $$ netperf ` + + for i in `pgrep -P $$ netperf ` # gets a list of PIDs for child processes named 'netperf' + do + #echo "Waiting for $i" + wait $i + done + + # Print TCP Download speed + echo "" + echo " $1: " `awk '{s+=$1} END {print s}' $SPEEDFILE` Mbps + + # When netperf completes, stop the dots and the pings + kill_pings + kill_dots + + # Summarize the ping data + summarize_pings $PINGFILE + + rm $PINGFILE + rm $SPEEDFILE +} + +# ------- Start of the main routine -------- + +# Usage: sh betterspeedtest.sh [ -4 -6 ] [ -H netperf-server ] [ -t duration ] [ -p host-to-ping ] [ -n simultaneous-sessions ] + +# “H” and “host” DNS or IP address of the netperf server host (default: netperf.bufferbloat.net) +# “t” and “time” Time to run the test in each direction (default: 60 seconds) +# “p” and “ping” Host to ping for latency measurements (default: gstatic.com) +# "n" and "number" Number of simultaneous upload or download sessions (default: 5 sessions; +# 5 sessions chosen empirically because total didn't increase much after that number) + +# set an initial values for defaults +TESTHOST="netperf.bufferbloat.net" +TESTDUR="60" +PINGHOST="gstatic.com" +MAXSESSIONS="5" +TESTPROTO=-4 + +# read the options + +# extract options and their arguments into variables. +while [ $# -gt 0 ] +do + case "$1" in + -4|-6) TESTPROTO=$1 ; shift 1 ;; + -H|--host) + case "$2" in + "") echo "Missing hostname" ; exit 1 ;; + *) TESTHOST=$2 ; shift 2 ;; + esac ;; + -t|--time) + case "$2" in + "") echo "Missing duration" ; exit 1 ;; + *) TESTDUR=$2 ; shift 2 ;; + esac ;; + -p|--ping) + case "$2" in + "") echo "Missing ping host" ; exit 1 ;; + *) PINGHOST=$2 ; shift 2 ;; + esac ;; + -n|--number) + case "$2" in + "") echo "Missing number of simultaneous sessions" ; exit 1 ;; + *) MAXSESSIONS=$2 ; shift 2 ;; + esac ;; + --) shift ; break ;; + *) echo "Usage: sh betterspeedtest.sh [-4 -6] [ -H netperf-server ] [ -t duration ] [ -p host-to-ping ] [ -n simultaneous-sessions ]" ; exit 1 ;; + esac +done + +# Start the main test + +if [ $TESTPROTO -eq "-4" ] +then + PROTO="ipv4" +else + PROTO="ipv6" +fi +DATE=`date "+%Y-%m-%d %H:%M:%S"` +echo "$DATE Testing against $TESTHOST ($PROTO) with $MAXSESSIONS simultaneous sessions while pinging $PINGHOST ($TESTDUR seconds in each direction)" + +# Catch a Ctl-C and stop the pinging and the print_dots +trap kill_pings_and_dots_and_exit HUP INT TERM + +measure_direction "Download" $TESTHOST $TESTDUR $PINGHOST $MAXSESSIONS +measure_direction " Upload" $TESTHOST $TESTDUR $PINGHOST $MAXSESSIONS + diff --git a/cerostats.sh b/cerostats.sh new file mode 100755 index 0000000..3bd9448 --- /dev/null +++ b/cerostats.sh @@ -0,0 +1,77 @@ +#! /bin/sh +# A collection of diagnostic commands to run when troubles arise. +# Based on Sebastian Moeller's original from: +# https://lists.bufferbloat.net/pipermail/cerowrt-devel/2014-April/002871.html +# +# The default script collects stats for the first 2.4GHz interface. +# Change for your situation. +# +# - phy0 - 2.4GHz radio +# - sw00 - First 2.4GHz wireless interface +# - /tmp/cerostats_output.txt - output file for stats + +radio=phy0 +wlan_if=sw00 +out_fqn=/tmp/cerostats_output.txt + +echo -e "[date]" > ${out_fqn} +date >> ${out_fqn} +echo -e "\n" >> ${out_fqn} + +echo -e "[uname -a]" >> ${out_fqn} +echo $( uname -a ) >> ${out_fqn} +echo -e "\n" >> ${out_fqn} + +echo -e "[uptime]" >> ${out_fqn} +echo $( uptime ) >> ${out_fqn} +echo -e "\n" >> ${out_fqn} + +echo -e "[ifconfig]" >> ${out_fqn} +ifconfig >> ${out_fqn} +echo -e "\n" >> ${out_fqn} + +echo -e "[top]" >> ${out_fqn} +top -b | head -n 20 >> ${out_fqn} +echo -e "\n" >> ${out_fqn} + +echo -e "[tc -s qdisc show dev ${wlan_if}]" >> ${out_fqn} +tc -s qdisc show dev ${wlan_if} >> ${out_fqn} +echo -e "\n" >> ${out_fqn} + +echo -e "[iw dev ${wlan_if} station dump]" >> ${out_fqn} +iw dev ${wlan_if} station dump >> ${out_fqn} +echo -e "\n" >> ${out_fqn} + +echo -e "[cat /sys/kernel/debug/ieee80211/${radio}/ath9k/ani]" >> ${out_fqn} +cat /sys/kernel/debug/ieee80211/${radio}/ath9k/ani >> ${out_fqn} +echo -e "" >> ${out_fqn} + +echo -e "[cat /sys/kernel/debug/ieee80211/${radio}/ath9k/interrupt]" >> ${out_fqn} +cat /sys/kernel/debug/ieee80211/${radio}/ath9k/interrupt >> ${out_fqn} +echo -e "" >> ${out_fqn} + +echo -e "[cat /sys/kernel/debug/ieee80211/${radio}/ath9k/queues]" >> ${out_fqn} +cat /sys/kernel/debug/ieee80211/${radio}/ath9k/queues >> ${out_fqn} +echo -e "" >> ${out_fqn} + +echo -e "[cat /sys/kernel/debug/ieee80211/${radio}/ath9k/xmit]" >> ${out_fqn} +cat /sys/kernel/debug/ieee80211/${radio}/ath9k/xmit >> ${out_fqn} +echo -e "" >> ${out_fqn} + +echo -e "[cat /sys/kernel/debug/ieee80211/${radio}/ath9k/recv]" >> ${out_fqn} +cat /sys/kernel/debug/ieee80211/${radio}/ath9k/recv >> ${out_fqn} +echo -e "" >> ${out_fqn} + +echo -e "[cat /sys/kernel/debug/ieee80211/${radio}/ath9k/reset]" >> ${out_fqn} +cat /sys/kernel/debug/ieee80211/${radio}/ath9k/reset >> ${out_fqn} +echo -e "" >> ${out_fqn} + +echo -e "[logread]" >> ${out_fqn} +logread >> ${out_fqn} +echo -e "\n" >> ${out_fqn} + +echo -e "[dmesg]" >> ${out_fqn} +dmesg >> ${out_fqn} +echo -e "" >> ${out_fqn} + +echo "Done... Stats written to ${out_fqn} (${0})" diff --git a/config-cerowrt.sh b/config-cerowrt.sh new file mode 100755 index 0000000..2d58ffa --- /dev/null +++ b/config-cerowrt.sh @@ -0,0 +1,234 @@ +#!/bin/sh +# Update the factory settings of CeroWrt to a known-good configuration. +# You should make a copy of this script, customize it to your needs, +# then use the "To run this script" procedure (below). +# +# This script is designed to configure all the settings needed to +# set up your router after an initial "factory" firmware flash. +# +# There are sections below to configure many aspects of your router. +# All the sections are commented out. There are sections for: +# +# - Set up the ge00/WAN interface to connect to your provider +# - Update the software packages +# - Update the root password +# - Set the time zone +# - Enable SNMP for traffic monitoring and measurements +# - Enable NetFlow export for traffic analysis +# - Enable mDNS/ZeroConf on the ge00 (WAN) interface +# - Change default IP addresses and subnets for interfaces +# - Change default DNS names +# - Set the SQM (Smart Queue Management) parameters +# - Set the radio channels +# - Set wireless SSID names +# - Set the wireless security credentials +# +# To run this script +# +# Flash the router with factory firmware. Then ssh in and execute these statements. +# You should do this over a wired connection because some of these changes +# will reset the wireless network. +# +# ssh root@172.30.42.1 +# cd /tmp +# cat > config.sh +# [paste in the contents of this file, then hit ^D] +# sh config.sh +# Presto! (You should reboot the router when this completes.) + +# === Set up the WAN (ge00) interface ================== +# Default is DHCP, this sets it to PPPoE (typical for DSL/ADSL) +# From http://wiki.openwrt.org/doc/howto/internet.connection +# Supply values for DSLUSERNAME and DSLPASSWORD +# and uncomment seven lines +# +# DSLUSERNAME=YOUR-DSL-USERNAME +# DSLPASSWORD=YOUR-DSL-PASSWORD +# uci set network.ge00.proto=pppoe +# uci set network.ge00.username=$DSLUSERNAME +# uci set network.ge00.password=$DSLPASSWORD +# uci commit network +# ifup ge00 + +# === Update the software packages ============= +# Download and update all the interesting packages +# Some of these are pre-installed, but there is no harm in +# updating/installing them a second time. +# opkg update # retrieve updated packages +# opkg install snmpd fprobe # install snmpd & fprobe +# opkg install qos-scripts # install the qos-scripts +# opkg install ppp-mod-pppoe # install PPPoE module + +# === Update root password ===================== +# Update the root password. Supply new password for NEWPASSWD and +# uncomment six lines. +# +# echo 'Updating root password' +# NEWPASSWD=Beatthebloat +# passwd < +# but doesn't have the nice GUI result. This can live in /usr/lib/sqm within CeroWrt +# +# When you start this script, it concurrently uploads and downloads multiple +# streams (files) to a server on the Internet. This places a heavy load +# on the bottleneck link of your network (probably your connection to the +# Internet). It also starts a ping to a well-connected host. It displays: +# +# a) total bandwidth available +# b) the distribution of ping latency + +# Usage: sh netperfrunner.sh [ -4 -6 ] [ -H netperf-server ] [ -t duration ] [ -t host-to-ping ] [ -n simultaneous-streams ] + +# Options: If options are present: +# +# -H | --host: DNS or Address of a netperf server (default - netperf.bufferbloat.net) +# Alternate servers are netperf-east (east coast US), netperf-west (California), +# and netperf-eu (Denmark) +# -4 | -6: IPv4 or IPv6 +# -t | --time: Duration for how long each direction's test should run - (default - 60 seconds) +# -p | --ping: Host to ping to measure latency (default - gstatic.com) +# -n | --number: Number of simultaneous sessions (default - 5 sessions) + +# Copyright (c) 2014 - Rich Brown rich.brown@blueberryhillsoftware.com +# GPLv2 + +# Summarize the contents of the ping's output file to show min, avg, median, max, etc. +# input parameter ($1) file contains the output of the ping command + +summarize_pings() { + + # Process the ping times, and summarize the results + # grep to keep lines that have "time=", then sed to isolate the time stamps, and sort them + # awk builds an array of those values, and prints first & last (which are min, max) + # and computes average. + # If the number of samples is >= 10, also computes median, and 10th and 90th percentile readings + sed 's/^.*time=\([^ ]*\) ms/\1/' < $1 | grep -v "PING" | sort -n | \ + awk 'BEGIN {numdrops=0; numrows=0;} \ + { \ + if ( $0 ~ /timeout/ ) { \ + numdrops += 1; \ + } else { \ + numrows += 1; \ + arr[numrows]=$1; sum+=$1; \ + } \ + } \ + END { \ + pc10="-"; pc90="-"; med="-"; \ + if (numrows == 0) {numrows=1} \ + if (numrows>=10) \ + { ix=int(numrows/10); pc10=arr[ix]; ix=int(numrows*9/10);pc90=arr[ix]; \ + if (numrows%2==1) med=arr[(numrows+1)/2]; else med=(arr[numrows/2]); \ + }; \ + pktloss = numdrops/(numdrops+numrows) * 100; \ + printf(" Latency: (in msec, %d pings, %4.2f%% packet loss)\n Min: %4.3f \n 10pct: %4.3f \n Median: %4.3f \n Avg: %4.3f \n 90pct: %4.3f \n Max: %4.3f\n", numrows, pktloss, arr[1], pc10, med, sum/numrows, pc90, arr[numrows] )\ + }' +} + +# ------- Start of the main routine -------- + +# Usage: sh betterspeedtest.sh [ -H netperf-server ] [ -t duration ] [ -p host-to-ping ] + +# “H” and “host” DNS or IP address of the netperf server host (default: netperf.bufferbloat.net) +# “t” and “time” Time to run the test in each direction (default: 60 seconds) +# “p” and “ping” Host to ping for latency measurements (default: gstatic.com) +# "n" and "number" Number of simultaneous upload or download sessions (default: 4 sessions; +# 4 sessions chosen to match default of RRUL test) + +# set an initial values for defaults +TESTHOST="netperf.bufferbloat.net" +TESTDUR="60" +PINGHOST="gstatic.com" +MAXSESSIONS=4 +TESTPROTO=-4 + +# Create temp files for netperf up/download results +ULFILE=`mktemp /tmp/netperfUL.XXXXXX` || exit 1 +DLFILE=`mktemp /tmp/netperfDL.XXXXXX` || exit 1 +PINGFILE=`mktemp /tmp/measurepings.XXXXXX` || exit 1 +# echo $ULFILE $DLFILE $PINGFILE + +# read the options + +# extract options and their arguments into variables. +while [ $# -gt 0 ] +do + case "$1" in + -4|-6) TESTPROTO=$1; shift 1 ;; + -H|--host) + case "$2" in + "") echo "Missing hostname" ; exit 1 ;; + *) TESTHOST=$2 ; shift 2 ;; + esac ;; + -t|--time) + case "$2" in + "") echo "Missing duration" ; exit 1 ;; + *) TESTDUR=$2 ; shift 2 ;; + esac ;; + -p|--ping) + case "$2" in + "") echo "Missing ping host" ; exit 1 ;; + *) PINGHOST=$2 ; shift 2 ;; + esac ;; + -n|--number) + case "$2" in + "") echo "Missing number of simultaneous sessions" ; exit 1 ;; + *) MAXSESSIONS=$2 ; shift 2 ;; + esac ;; + --) shift ; break ;; + *) echo "Usage: sh Netperfrunner.sh [ -H netperf-server ] [ -t duration ] [ -p host-to-ping ] [ -n simultaneous-streams ]" ; exit 1 ;; + esac +done + +# Start main test + +if [ $TESTPROTO -eq "-4" ] +then + PROTO="ipv4" +else + PROTO="ipv6" +fi +DATE=`date "+%Y-%m-%d %H:%M:%S"` +echo "$DATE Testing $TESTHOST ($PROTO) with $MAXSESSIONS streams down and up while pinging $PINGHOST. Takes about $TESTDUR seconds." +# echo "It downloads four files, and concurrently uploads four files for maximum stress." +# echo "It also pings a well-connected host, and prints a summary of the latency results." +# echo "This test is part of the CeroWrt project. To learn more, visit:" +# echo " http://bufferbloat.net/projects/cerowrt/" + +# Start Ping +if [ $TESTPROTO -eq "-4" ] +then + ping $PINGHOST > $PINGFILE & +else + ping6 $PINGHOST > $PINGFILE & +fi +ping_pid=$! +# echo "Ping PID: $ping_pid" + +# Start $MAXSESSIONS upload datastreams from netperf client to the netperf server +# netperf writes the sole output value (in Mbps) to stdout when completed +for i in $( seq $MAXSESSIONS ) +do + netperf $TESTPROTO -H $TESTHOST -t TCP_STREAM -l $TESTDUR -v 0 -P 0 >> $ULFILE & + # echo "Starting upload #$i $!" +done + +# Start $MAXSESSIONS download datastreams from netperf server to the client +for i in $( seq $MAXSESSIONS ) +do + netperf $TESTPROTO -H $TESTHOST -t TCP_MAERTS -l $TESTDUR -v 0 -P 0 >> $DLFILE & + # echo "Starting download #$i $!" +done + +# Wait until each of the background netperf processes completes +# echo "Process is $$" +# echo `pgrep -P $$ netperf ` + +for i in `pgrep -P $$ netperf` # get a list of PIDs for child processes named 'netperf' +do + # echo "Waiting for $i" + wait $i +done + +# Stop the pings after the netperf's are all done +kill -9 $ping_pid +wait $ping_pid 2>/dev/null + +# sum up all the values (one line per netperf test) from $DLFILE and $ULFILE +# then summarize the ping stat's +echo " Download: " `awk '{s+=$1} END {print s}' $DLFILE` Mbps +echo " Upload: " `awk '{s+=$1} END {print s}' $ULFILE` Mbps +summarize_pings $PINGFILE + +# Clean up +rm $PINGFILE +rm $DLFILE +rm $ULFILE diff --git a/networkhammer.sh b/networkhammer.sh new file mode 100644 index 0000000..7b72625 --- /dev/null +++ b/networkhammer.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# Continuously hammer the network with continuous netperfrunner tests +# Initially created to put load on Wi-Fi for CeroWrt +# + +echo "Hammering the network to gw.home.lan. Hit Ctl-C to cancel" +while True; +do + ./netperfrunner.sh -H gw.home.lan +done diff --git a/tunnelbroker.sh b/tunnelbroker.sh new file mode 100644 index 0000000..0947a0f --- /dev/null +++ b/tunnelbroker.sh @@ -0,0 +1,137 @@ +#!/bin/sh +# Script for setting CeroWrt to create an IPv6 tunnel +# to Hurricane Electric at http://www.tunnelbroker.net/ +# There are two steps: +# 1) Go to the Tunnelbroker.net site to set up your free account +# 2) Run the script below, using the parameters supplied by Tunnelbroker +# This CeroWrt page gives detailed instructions for setting up an IPv6 tunnel: +# http://www.bufferbloat.net/projects/cerowrt/wiki/IPv6_Tunnel +# +# Once you've created your account and a tunnel, get the "Example +# Configurations" for OpenWRT Backfire, and use the info to fill in this +# file, then save it as a file named "tunnel.sh" Finally, ssh into the +# router and execute this script with these steps: +# +# ssh root@172.30.42.1 +# cd /tmp +# cat > tunnel.sh +# [paste in the contents of this file, then hit ^D] +# sh tunnel.sh +# [Restart your router. This seems to make a difference.] +# +# Presto! Your tunnel is set up. You should now be able +# communicate directly with IPv6 devices. + +# ============================================== +# Download and update all the interesting packages +# Some of these are pre-installed, but there is no +# harm in updating/installing them a second time. +opkg update +opkg install 6in4 + +# ============================================== +# Create a 6in4 interface to tunnel IPv6. These steps show how to +# set the credentials for a Hurricane Electric tunnel +# First create an account at http://HE.net, then use their +# Example Configurations page to get the specifics, which are +# automatically generated specifically for *your* tunnel +# Copy/paste the information from the Example Configurations +# generated for the OpenWRT Backfire 10.03.1 dropdown +# then edit the following to match your parameters. +# +# NOTE: The username should be your plain UserID (the "Account Name: +# on the tunnelbroker.net site) not the long alphanumeric string +# +echo 'Setting up HE.net tunnel' +# ------- USE THE INFORMATION FROM TUNNELBROKER.NET HERE -------- +uci set network.henet=interface +uci set network.henet.proto=6in4 +uci set network.henet.peeraddr=xxx.xxx.xxx.xxx +uci set network.henet.ip6addr='2001:470:ABCD::2/64' +uci set network.henet.tunnelid=123456 +uci set network.henet.username='your-plain-userid' +uci set network.henet.password='your-password' +# ------- END OF TUNNELBROKER.NET INFO -------- + +# ------- Additional configuration info required for the tunnel -------- +# This automatically assigns each LAN interface a /64 from your routed /48 +# Set the ip6prefix to use your routed /48 prefix from HE.net +uci set network.henet.ip6prefix='2001:470:ABCD::/48' +uci set network.henet.mtu=1424 +uci set network.henet.ttl=64 +uci commit network + +# ============================================== +# Configure the 6in4-henet interface into the WAN zone +# CeroWrt puts WAN stuff in zone[0], not zone[1] as with OpenWrt +uci set firewall.@zone[0].network='ge00 henet' +uci commit firewall + +# ============================================== +# Invoke the new configuration +echo 'Restarting network... "Device busy (-16)" messages are OK.' +/etc/init.d/network restart +echo 'Restarting firewall...' +/etc/init.d/firewall restart + +# Belt and suspenders - you could also restart +echo 'Done. You should restart the router now to make these take effect.' + +# ============================================== +# What's going on here? +# +# CeroWrt is configured to do a lot of stuff automatically, so you may not notice +# all the magic that's happening under the covers. Here are some of the configuration +# tricks that have been worked out over the various test releases of CeroWrt 3.10.x +# +# IPv6-in-IPv4 tunnel to Hurricane Electric (http://HE.net): +# +# These lines create an interface named "6in4-henet" that acquires an IPv6 address +# for the CeroWrt router, and also gets the assigned /48 prefix to assign to the +# individual routed LAN interfaces. +# +# In addition, the script places 6in4-henet into the firewall's WAN zone. +# +# DNS/DHCP: +# +# dnsmasq-dhcpv6 is the default DNS and DHCP server. By default, it is prepared +# to handle all DNS duties and to hand out IPv4 and IPv6 addresses. +# Each time it restarts, its config file (/etc/config/dhcp) is compiled to +# create /var/etc/dnsmasq.conf. This in turn links to a conf file at +# /etc/dnsmasq.conf. The latter file contains the information required for +# handing out IPv6 addresses on the LAN interfaces (se00, sw00, gw00, sw10, gw10). +# +# Restarting services: +# +# The final step in the script is to restart the network and firewall services. +# It never hurts to reboot the router after this completes. +# +# NB: This has been tested with CeroWrt 3.10.50-1 (July 2014) + +# ============================================== +# Re-establishing the Tunnel +# +# NB: As of CeroWrt 3.7.5-2 (Feb 2013), the automatic re-establishment code +# of the 6in4 module appears not to be working. You will need to re-establish +# the tunnel manually when your external IP address changes. +# +# To re-establish the tunnel, say, because your external IP address changed, +# you can also use the following URL with these parameters. Note that the +# USERNAME and PASSWORD are what you type to log into the Tunnelbroker site. +# +# USERNAME is the Account Name +# PASSWORD is the current password +# TUNNELID is the Tunnel ID +# https://USERNAME:PASSWORD@ipv4.tunnelbroker.net/ipv4_end.php?tid=TUNNELID +# +# You can also use a non-HTTPS URL and parameters to re-establish the link. +# This form relies on hashed representations of the credentials since they're +# not carried on a secure connection. You can get more information about the +# parameters at https://ipv4.tunnelbroker.net/ipv4_end.php +# +# USERID is the "User ID" from the Tunnelbroker site's Main Page +# PWHASH is the MD5 hash of the password +# TUNNELID is the Tunnel ID +# http://ipv4.tunnelbroker.net/ipv4_end.php?ip=AUTO&apikey=USERID&pass=PWHASH&tid=TUNNELID +# +# --- end of script ---