You! Stuck in a hotel? Want Wi-Fi?
Here’s two scripts you can run if you have a 3G card, and a few friends stuck in the hotel room with you who want WiFi.
First, turn your laptop into an access point. These scripts work on MacOS X running 10.5.4 or better — good luck!
I call this script ‘make-me-an-access-point.sh’:
#!/bin/sh #Edit your /etc/rc.conf to set the option firewall_enable to YES # Edit your /etc/rc.firewall to add lines: /usr/sbin/natd -dynamic -interface ppp0 sysctl -w net.inet.ip.forwarding=1 /sbin/ipfw -f flush /sbin/ipfw add 1000 pass all from 127.0.0.1 to 127.0.0.1 /sbin/ipfw add 2000 divert natd ip from any to any via ppp0 /sbin/ipfw add 6500 pass all from any to any ifconfig en1 192.168.1.1 up netmask 255.255.255.0 broadcast 192.168.0.255 dhcpd
and when you want this to go away, do:
laptop:bin jna$ cat undo-make-me-an-access-point.sh
#!/bin/sh
#
# undo the make-me-an-access-point script
#
sysctl -w net.inet.ip.forwarding=0
sudo /sbin/ipfw -f flush
sudo kill -9 `ps -efl | grep dhcp | egrep -v VMware | awk '{ print $2 }'`
echo "Now turn off the Airport, then wait a moment, and turn it back on."
The contents of my dhcpd.conf are very simple:
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#
ddns-update-style ad-hoc;
# option definitions common to all supported networks...
option domain-name "retina.net";
option domain-name-servers 209.183.50.151;
default-lease-time 600;
max-lease-time 7200;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option routers 192.168.1.1;
option domain-name-servers 206.13.28.12;
option broadcast-address 192.168.1.255;
}
I used to play intellivision at your house on the corner of Menlo and Bouve, just wanted to say hello.
Do you think it's possible to port this script to the iphone? If it needs porting at all…
Thanks for the useful information, but I want to add something important. Don't know if you have seen “The Real Hustle” series, but wireless networks can be quite vulnerable and in a hotel it often happens for you to pay with your credit card for wi-fi access. Credit card details are the honey and butter of such high-tech hustlers.
<< Hotel Supplies >>
Interesting post. I have made a twitter post about this. Others no doubt will like it like I did.