An Easy Button to Change Your IP Address!

Transcription

An Easy Button to Change Your IP Address!
An Easy Button to Change Your IP Address!
By Vitad Pradith
Almost every seasoned HYPACK® user has gone through the rite of passage mastering the
task of setting your IP address (Static IP), but some of you have taken it to the next level and
can even recite the cursor placement and what links to click in Windows® to reach the
infamous "Internet Protocol Version v4 (TCP/IP v4)" option. But given the array of sonar
systems that utilize an Ethernet connection and computers/laptops that come with only one
Ethernet (RJ45) port, someone is going to end up with Carpal Tunnel from all that button
clicking. So, if you're like me and love little hacks that will save you a little time and physical
aggravation then this is for you.
In this article, I'm going to show you how to use the Microsoft command line tool Netsh that is
well known to IT Network Administrators, convert it into a batch file that will allow you to
quickly swap your IP address by clicking on a desktop shortcut.
NOTE: You must have administrator privileges to do this!!
The batch file allows you to configure several executables to adjust your IP address based on
your sensor du jour (e.g. side scan, multibeam, magnetometers, or really anything with an IP
address).
1.
Find the name of your Network Port. Select CONTROL PANEL > NETWORK AND
SHARING CENTER > CHANGE ADAPTER SETTINGS.
FIGURE 1. Found Under the Network Connections Folder
2.
Note the name. In my example, my on board Ethernet port is named "Widget".
May / 2015
1
Currently, this Ethernet port is set to obtain an IP address automatically. This is known as
DHCP (Dynamic Host Configuration Protocol).
FIGURE 2.
3.
Ethernet port is set to obtain an IP address automatically
Take an inventory of the sensors and respective IP addresses between which you
want to switch. For example, I have two separate sensors with the following IP
characteristics:
Sensor1 IP:111.111.111.111 Subnet: 255.255.255.0
Sensor2 IP:222.222.222.222 Subnet: 255.255.255.0
4.
In a text editor such as NotePad, type or copy/paste the following code, changing
the name of the port and IP address to reflect your network port name and IP address:
netsh int ip set address "Widget" static 111.111.111.111 255.255.255.0
netsh interface ip dump
pause
exit
Example:
netsh int ip set address "My Network Port" static 192.168.0.1
255.255.255.0
netsh interface ip dump
pause
exit
5.
2
Name and save the file as a *.bat file. (Set your Save As Type to All Files(*.*).)
FIGURE 3. Saving the Batch File
6.
7.
Save your file to the desktop (or somewhere convenient).
Test the batch file. Right-click on the file and select Run as Administrator.
FIGURE 4. Test Running the Batch
If you haven't disabled the Windows UAC, you will see a
Windows® Warning message. Click OK to execute the
batch file.
A Windows® command line window should appear
confirming that your IP address for that particular port has
changed!
FIGURE 5. Windows®
Confirms
the
Address
Change
May / 2015
3
If you really need a warm and fuzzy, you can confirm that the IP address changed through
the usual button clicking method.
FIGURE 6. After Executing Sensor 1
8.
Repeat the above steps for your other sensors!
FIGURE 7. After Executing Sensor 2
RESETTING YOUR PORT TO DHCP
To reset the port back to DHCP, use the following code replacing "Widget" with the name of
your port. Save this file to something obvious such as "DHCP.bat"
netsh interface ip set address "Widget" dhcp
pause
exit
Carpal tunnel be gone!
4
SOME MORE TROUBLESHOOTING TIPS & TRICKS
•
Incorrectly Referenced Port Name. If the Command window looks like Figure 8, you
probably forgot to right-click and run as an administrator (or you're not an administrator).
If you “make nice” with your local IT help, they may be able to permanently give you this
file administrator privileges.
FIGURE 8. Running the Batch Without Administrative Permissions
•
•
Batch File Shortcuts: If right-clicking to "Run as administrator" is really annoying, you
can put the files into a folder and make shortcut icons to the batch files:
a. Right-click on the batch file shortcut and select Properties.
b. Click on the Shortcut tab.
c. Click [Advanced].
d. Select the "Run as administrator" option.
This is a Windows quirk to run the batch file as an administrator all the time.
For more information:
https://support.microsoft.com/en-us/kb/257748
May / 2015
5