ncutil 3User's Guide |
Locations and Services |
Today's computers typically have more than one network interface associated with them: my PowerBook G4 has a 56k modem, built-in ethernet, AirPort wireless card, and Bluetooth modem capability. And the fact that the computer in question is a laptop implies that I may need to have configuration information available for many different locales.
The SystemConfiguration framework and the configd daemon that run on every Darwin-based host make it easy to juggle all these interfaces and a myriad of configurations. A network service consists of a reference to the network interface it configures and properties to setup each protocol that run atop that interface. For example, Listing 8 shows the contents of a network service that is associated with the built-in ethernet interface:Here we see that the Built-in Ethernet interface is used by the network service and protocol configuration entities for AppleTalk, IP version 4 and 6, DNS, and proxy server settings are all present.
Listing 8: A Built-in Ethernet network service. [0 ]$ list 9 drw 10 Built-in Ethernet Interface drw 11 Proxies Protocol drw 12 AppleTalk Protocol drw 13 IPv4 Protocol drw 14 DNS Protocol drw 15 IPv6 Protocol
A location (also called a network set) contains multiple network services, one for each available network interface, typically. Of course, one can remove or add network services to a location: if no network services exist for a particular interface then that interface simply is not configured when that location is in-use. If in the context of a location multiple network services exist for a single interface, then the service order for that location determines in what sequence each network service will be consulted in order to get the network interface transmitting.In this case, there are two network services associated with the built-in ethernet interface: the first (Built-in Ethernet) uses a static IP address while the second (DHCP) requests an address from a DHCP server. If the interface were to fail to come up with the first service's static address, the second service would be tried.
Listing 9: The name and service order for the Office location. [0 ]$ read 7 -rw name = Office -rw service-order = { Built-in Ethernet DHCP Built-in FireWire Internal Modem Bluetooth AirPort }
Let us see how locations and network services are created and removed using ncutil.
Creating a Location
Each location must have a unique name to identify it to the user, so first choose a name for the new location (you can modify the name later, too). We will create a new location called At Home. The command to create this new location is quite simple:The new location is automatically populated with one network service for each available network interface.
Listing 10: Creating and examining the At Home location. [0 ]$ create-location "At Home" [0 ]$ ls dr- 1 Interfaces Directory drw 7 Office Location drw 45 On the Road Location drw 90 At Home Location [0 ]$ ls 90 drw 91 NetInfo Global NetInfo drw 92 Internal Modem Service drw 99 Bluetooth Service drw 106 Built-in Ethernet Service drw 113 Built-in FireWire Service drw 119 AirPort Service
Creating a Network Service
Having configured all of the network services in the At Home location (in a flurry of commands not cited here) we shall now add another network service to use DHCP to configure the built-in ethernet interface. As with locations, each network service within a location should have a unique name associated with it: we will call the new service DHCP. Listing the /Interfaces directory, we find that the built-in ethernet template resides at directory ID 4 (or /Interfaces/Built-in Ethernet). The location to which you wish to add the new service must be the first argument to the command; the network interface template directory is the second argument; and the name for the service is the third.In the next chapter we will configure this new network service, but for now, let us move on to removing services and locations.
Listing 11: Creating and examining the DHCP service. [0 ]$ create-service 90 4 DHCP [0 ]$ ls 90 drw 91 NetInfo Global NetInfo drw 92 Internal Modem Service drw 99 Bluetooth Service drw 106 Built-in Ethernet Service drw 113 Built-in FireWire Service drw 119 AirPort Service drw 127 DHCP Service [0 ]$ ls 127 drw 128 Built-in Ethernet Interface drw 129 IPv4 Protocol drw 130 DNS Protocol drw 131 IPv6 Protocol drw 132 AppleTalk Protocol drw 133 Proxies Protocol
Removing a Network Service
To remove a network service, make note of its directory ID or path and then issue the destroy-service {directory} command. That's it.
Removing a Location
You cannot remove the current location, so first and foremost the current location must be switched if this is the case. The name of the current location is a property of the root directory.A location is removed using the destroy-location {directory} command, where the directory is the directory ID or path of the location to be removed.
Listing 12: Determining the current location. [0 ]$ readprop 0 current-location Office
Previous Chapter Table of Contents Next Chapter
| Copyright © 2005 | Jeffrey T. Frey |