Networking

Revised: 2008-11-15 james

Networking

Date:                Friday, November 14th, 2008
Time:                2:00 - 3:30 pm
Where:                Marriott Library, Multimedia Center, Classroom 1705A

It is assumed you know:
- Basic terminal navigation and usage
Class will cover:
- System Configuration Framework (configd) and using scutil
- Editing Mac OS X network preferences (ncutil, /Library/Preferences/SystemConfiguration/prefereces.plist)
- hping2
- netstat
- ipfw

Class Notes from February 2008

Chapter 8

System Configuration framework and network preferences

configd

Tools:

scutil - set computer name, find location

set computer name:
sudo scutil --set ComputerName name
sudo scutil --set HostName name

set the dns server w/ scutil:

http://www.afp548.com/article.php?story=20050703052052393

---

ARD commands

10.4 locations
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/systemsetup
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/networksetup

10.5 locations
/usr/sbin/networksetup
/usr/sbin/systemsetup

Examples

networksetup -setappletalk Ethernet on
networksetup -setdnsservers Ethernet 155.101.115.10 155.101.201.10

---

ncutil

http://deaddog.duch.udel.edu/ncutil/
http://deaddog.duch.udel.edu/ncutil/UsersGuide/

Turning on appletalk 10.4:

ncutil setprop "/Automatic/Built-in Ethernet/AppleTalk" method Node
ncutil --apply-on-exit destroyprop "/Automatic/Built-in Ethernet/AppleTalk" inactive

I could not get this to work in 10.5

---

The file:

/Library/Preferences/SystemConfiguration/preferences.plist

#!/usr/bin/perl

sub reload_preferences_plist {
    my @scutil = `scutil <<- end_scutil 2> /dev/null
open
show Setup:/
close
end_scutil`;
    my @matches = map { m/UserDefinedName : (.*)/ } @scutil;
    if(@matches == 1) {
        `scselect $matches[0]`;
    }
}


----------

kicker in 10.4

/System/Library/SystemConfiguration/Kicker.bundle/Contents/Resources/Kicker.xml
/System/Library/SystemConfiguration/Kicker.bundle/Contents/Resources/enable-network

http://www.macgeekery.com/gspot/2006-05/hacking_kicker_and_configd_to_run_your_scripts

Kinda kicker for 10.5

http://code.google.com/p/pymacadmin/

or LocationChanger

http://www.ghoselab.cmrr.umn.edu/software.html

Or there are several ways to do the following:

This is a launchdaemon, save to /Library/LauchDaemons

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
    "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.magnusviri.kicker</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/kicker.sh</string>
    </array>
    <key>WatchPaths</key>
    <array>
        <string>/Library/Preferences/SystemConfiguration</string>
    </array>
</dict>
</plist>



#!/bin/sh

# redirect all IO to /dev/null (comment this out if you want to debug)
exec 1>/dev/null 2>/dev/null

sleep 2

# get various system information
SSID=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I\
 | grep ' SSID:' | cut -d ':' -f 2 | tr -d ' '`

if [ "$SSID" = "uconnect.utah.edu" ]; then
    say u connect
else
    say unknown network
fi


------------

hping2
802.1x setup & loginwindow
ifconfig
lsof
tcpdump
flush the cache 10.4
    lookupd -flushcache
flush the cache 10.5
    dscacheutil -flushcache.

netstat

getting MAC or IP from command line
is network active at startup?

ipfw