Like many others out there, I use Brian Hill's BrickHouse tool to configure OS X's firewall and internet connection sharing (NAT). My Mac acts as a gateway/firewall -- the built-in Ethernet port connects to a cable modem, and this connection is shared across the wireless network.
This works great -- but there was one problem. If the Mac was put to sleep, after waking up there would be no internet access for either the Mac or the wireless clients. Attempting to renew the DHCP lease failed, always returning a 169.x.x.x self-assigned address. I found out that running /Library -> StartupItems -> Firewall -> Firewall restart at the Terminal (as root, so use sudo!) to re-apply the firewall and NAT settings brought everything back to life. I just needed a way to make this happen automatically when the Mac woke from sleep.
After a bit of looking through the system.log file during a sleep/wake cycle, and a bit of googling, I found the Kicker.xml file which the Configuration Manager (configd) consults when certain system events occur. To make the Firewall reinitialise when the computer wakes, first open the Kicker.xml file (one long line, shown as two with a continuation backslash):
sudo pico /System/Library/SystemConfiguration/\
Kicker.bundle/Contents/Resources/Kicker.xml
Then, add the following XML to the end of the file, after the last </dict>, but before the last two </array></plist> entries:
<dict>
<key>execCommand</key>
<string>/Library/StartupItems/Firewall/Firewall restart</string>
<key>execUID</key>
<integer>0</integer>
<key>keys</key>
<array>
<string>State:/Network/Global/IPv4</string>
</array>
<key>name</key>
<string>restart_firewall</string>
<key>postName</key>
<string>com.apple.system.config.network_change</string>
</dict>
Save that, then restart configd (again, as root):
kill -HUP `cat /var/run/configd.pid
Now, whenever there's a wake-from-sleep (or any other significant network change event, for that matter), the firewall and NAT settings will be reapplied. Hope this is useful to some people!
Mac OS X Hints
http://hints.macworld.com/article.php?story=20031220155500113