2007-01-13

Change IP Address in a Script

We usually change the IP address of the network card of our computer with a graphic tool. This work can also be done in a command prompt. Sometimes it is useful. Follow me:

C:\>ipconfig
Windows 2000 IP Configuration

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 10.0.127.235
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 10.0.127.1

C:\>netsh
netsh>i
interface>i
interface ip>sh a

Configuration for interface "Local Area Connection"
DHCP enabled: No
IP Address: 10.0.127.235
SubnetMask: 255.255.255.0
Default Gateway: 10.0.127.1
GatewayMetric: 1
InterfaceMetric 1

interface ip>set a "Local Area Connection" static 192.168.16.44 255.255.255.0 192.168.16.5 1
Ok.

interface ip>sh a

Configuration for interface "Local Area Connection"
DHCP enabled: No
IP Address: 192.168.16.44
SubnetMask: 255.255.255.0
Default Gateway: 192.168.16.5
GatewayMetric: 1
InterfaceMetric 1

interface ip>exit

C:\>ipconfig

Windows 2000 IP Configuration

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 192.168.16.44
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.16.5

If you want to set it as DHCP, try this:

interface ip>set a "Local Area Connection" source=dhcp

Administrator permission is required for this work.

0 Comments:

Post a Comment

<< Home