This is a DiscontinuedProject. It has been finished and is in a stable state now. Currently, no effort is made for further work here.
I wanted my notebook (running FreeBSD) to connect to the Internet automatically when booting, if a network is available.
As the Internet might be reachable through several ways (e.g. the builtin Fast Ethernet interface, the builtin WLAN card, a USB dongle providing Bluetooth access to the GPRS-enabled mobile phone), the connection mechanism must be able to find the right transport to use and then do the right things to connect.
I also want to be able to boot up without any networking support, and then manually start a connection - which comes handy when being "in the wild" and wanting to start up a short networked session over the mobile phone.
The scripts I have hacked for this purpose work like this at boot time:
- Check if notebook's WLAN switch is on. If so, start WLAN connection
- If not, start connection over Fast Ethernet interface
- If, after three minutes, DHCP has not got an IP address, shut down Fast Ethernet and stay offline
When called manually, the script can also do some more things:
- Shut down network completely
- Start rfcomm_pppd as client for GPRS on the cellphone through Bluetooth USB stick
- Start any of the other network connections mentioned above as desired
The main script is lan.sh, which is called without arguments at boot time (through a start script in /usr/local/etc/rc.d/. If this chooses to start a connection over the Fast Ethernet line (in my case, it's an re0 interface), it also starts a watcher script, re0watch, which checks for an IP after three minutes and, if none is there, stops the DHCP client again to save resources and keep the log clean.
When using this script, it is important that no network interfaces are configured in /etc/rc.conf for setup at boot time, as this would break the housekeeping done by this script. Keeping and verifying state (as in dhclient running or not, which interface is being used right now) is a thing that could be improved in lan.sh anyways, maybe I will put some more time into this one day. In the meantime, you may want to use this script as a starting point.
This script works hand in hand with some network profiling system (doing things like automatic SOCKS proxy configuration when needed, for example). To make this work, and use features like NTP, I also use dhclient-enter-hooks and dhclient-exit-hooks - which in turn call some other scripts. mailaway and lpdaway might be starting points for further own scripting.
THIS DATA IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS DATA, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
All product and brand names mentioned on there pages and in the source code are registered names and/or trademarks of the respective owner and are mentioned for identification purposes only.
For a full copyright notice, please see this link. For imprint and contact information, please see http://www.thiemo.net/.