40

Viewing or Changing IP Address, Subnet Mask, or Router Address

You can use the serversetup and networksetup commands to change a computer’s TCP/IP settings.

Important: Changing a server’s IP address isn’t as simple as changing the TCP/IP settings. You must first run the changeip utility to make sure necessary changes are made throughout the system. See “Changing a Server’s IP Address” on page 39.

To list TCP/IP settings for a configuration:

$ sudo networksetup -getinfo "configuration"

Example:

$ networksetup -getinfo "Built-In Ethernet" Manual Configuration

IP Address: 192.168.10.12

Subnet mask: 255.255.0.0

Router: 192.18.10.1

Ethernet Address: 1a:2b:3c:4d:5e:6f

To view TCP/IP settings for port en0:

$ serversetup -getDefaultinfo (devicename"portname")

To view TCP/IP settings for a particular port or device:

$ serversetup -getInfo (devicename"portname")

To change TCP/IP settings for a particular port or device:

$ sudo serversetup -setInfo (devicename"portname") ipaddress subnetmask

router

To set manual TCP/IP information for a configuration:

$ sudo networksetup -setmanual "configuration" ipaddress subnetmask router

To validate an IP address:

$ serversetup -isValidIPAddress ipaddress

Displays 0 if the address is valid, 1 if it isn’t.

To validate a subnet mask:

$ serversetup -isValidSubnetMask subnetmask

To set a configuration to use DHCP:

$ sudo networksetup -setdhcp "configuration" [clientID]

To set a configuration to use DHCP with a manual IP address:

$ sudo networksetup -setmanualwithdhcprouter "configuration" ipaddress

To set a configuration to use BootP:

$ sudo networksetup -setbootp "configuration"

Chapter 5 Network Preferences

Page 40
Image 40
Apple oxs To list TCP/IP settings for a configuration, To view TCP/IP settings for port en0, To validate an IP address