Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Restore networking after sleep with Brickhouse Firewall Network

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!
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[7,494 views]  

Restore networking after sleep with Brickhouse Firewall | 4 comments | Create New Account
Click here to return to the 'Restore networking after sleep with Brickhouse Firewall' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Restore networking after sleep with Brickhouse Firewall
Authored by: partylikechewie on Jan 14, '04 10:02:25AM

What about restoring network connectivity if the machine is not using Brickhouse and it loses network connectivity coming out of sleep mode? Is there an easy way to do that?



[ Reply to This | # ]
Restore networking after sleep with Brickhouse Firewall
Authored by: vinylone on Jan 18, '04 08:25:38PM

This may be a goofy question, but i'm struggling with lines 7 and 9:

<key>keys</key>
is the key value my wep key?

<key>name</key>
is the name value my SSID?

or am I overanalyzing this, and the script is as-written?

before i give it a whirl (not running the firewall, and running Panther 10.3) I figure i'd ask....

regards,

Eric Lecht



[ Reply to This | # ]
Restore networking after sleep with Brickhouse Firewall
Authored by: vinylone on Jan 18, '04 08:56:10PM

Shoot, the more i look at that xml stanza the less confident i am of mucking about where I haven't a clue. Line 2 references the Firewall (the way I read it), and since i'm not RUNNING the firewall......
Back to MacAddict, and the thread i'm working on my G4 Powerbook/Panther 10.3 losing its network settings on sleep...
I see this hint had an initial query regarding this very thing...was there ever an answer here?

thanks LOADS in advance,

Eric Lecht



[ Reply to This | # ]
Restore networking after sleep with Brickhouse Firewall
Authored by: gboudrea on Jan 29, '05 08:54:04AM

Use as-is.
<key/> tags are use to define the name of the parameters.
It's value follows...

So, for example, to define someParam=something, you'd have to use this syntax in the xml file:
<key>someParam</key>
<string>something</string>

- Mouton



[ Reply to This | # ]