Well folks we're all sitting here at this pretty core screen on Server 2008. The cursor is just a blinking away on "C:\Users\Administrator". Just teasing you and poking fun at you.
"No GUI! Come on! Gimme your worst!"
You feel so helpless.
But you aren't.
Helpless would be un-armed. No way to work. System useless.
Today we're going to play a little bit with NETSH.EXE
"And just what is THAT?!" they're all screaming at the back.
Potatoes fly down. "I thought you were going to tell us something useful! We just use that sometimes after spyware!"
Well in truth you do. NETSH INTERFACE IPV4 RESET is a nice simple way to reset the Winsock in your system. But that's not ALL it does. Do you think Microsoft put it there BECAUSE of Malware?
NETSH.EXE is your command line version of "Network Connections" or "Network Sharing Center". This is your magic box to get into network card settings.
Now NETSH.EXE like a LOT of the command based utilities is incredibly powerful. I particularly like it since it has both a regular "Shell" to dip into which actually has a simple and useful help system.
It can also be pre written up as a batch file or scriptable command line.
If you just typed in your old familiar NETSH INTERFACE IPV4 RESET you would have just seen it say "Yeah ok, whatever." and finished it's job.
If however you typed in NETSH.EXE by itself you'd get
Seems to be prompting you for something doesn't it?
Key in either "help" or "?" and hitting enter will open up this little world.
The following commands are available:
Commands in this context:
.. - Goes up one context level.
? - Displays a list of commands.
abort - Discards changes made while in offline mode.
add - Adds a configuration entry to a list of entries.
advfirewall - Changes to the `netsh advfirewall' context.
alias - Adds an alias.
bridge - Changes to the `netsh bridge' context.
bye - Exits the program.
commit - Commits changes made while in offline mode.
delete - Deletes a configuration entry from a list of entries.
dhcp - Changes to the `netsh dhcp' context.
dhcpclient - Changes to the `netsh dhcpclient' context.
dump - Displays a configuration script.
exec - Runs a script file.
exit - Exits the program.
firewall - Changes to the `netsh firewall' context.
help - Displays a list of commands.
http - Changes to the `netsh http' context.
interface - Changes to the `netsh interface' context.
ipsec - Changes to the `netsh ipsec' context.
lan - Changes to the `netsh lan' context.
nap - Changes to the `netsh nap' context.
netio - Changes to the `netsh netio' context.
offline - Sets the current mode to offline.
online - Sets the current mode to online.
p2p - Changes to the `netsh p2p' context.
popd - Pops a context from the stack.
pushd - Pushes current context on stack.
quit - Exits the program.
ras - Changes to the `netsh ras' context.
rpc - Changes to the `netsh rpc' context.
set - Updates configuration settings.
show - Displays information.
unalias - Deletes an alias.
winhttp - Changes to the `netsh winhttp' context.
winsock - Changes to the `netsh winsock' context.
wlan - Changes to the `netsh wlan' context.
The following sub-contexts are available:
advfirewall bridge dhcp dhcpclient firewall http interface ipsec lan nap netio
p2p ras rpc winhttp winsock wlan
To view help for a command, type the command, followed by a space, and then
"WHOA!" I can hear you say. "THAT'S inside NETSH.EXE?"
That's right. Now the fun part is playing with it. Let's try something simple. I'll go in step by step. Mostly because I personally can't remember all the command structure. Setting an IP address. This is of course PRESUMING you have a network card installed. Of some type.
Now I can do the showoff version which says "JUST TYPE THIS IN, IN ONE SHOT. NOW GO AWAY AND STOP BOTHERING ME FOR ANSWERS."
I COULD do that, but that would be rude and not very interesting.
So enter the "Net Shell"
NETSH (Of course hit Enter, really, you DO have to.... Hey who threw that?)
Now at this prompt type "interface" to choose the particular interface you're going to work with
netsh>interface <ENTER> (Don't type <ENTER> or this won't work.... Hey you at the back, I know where you live)
Is your new prompt. You see as you go in it will remind you what you're doing. This will also be part of the context if you ever wanted to write this as a batch file and drop it onto another system.
now choose tcp since we're going to work with TCP/IP. By the way, I'm not picking "random words". If you're curious where they're coming from, any time, key in "?" or "HELP" to get a gander what you can do at each level of the tree.
netsh inteface>tcp (We'll skip all the Enter jokes from here on in, that joker at the back is really pelting me)
Today we're going to work with IPV4. What you didn't read? There's more than one version of TCP/IP. We want to work with THAT version. I'm certain we're all running a TCP/IP V6 class network in our house.
netsh interface tcp>ipv4
Now at all these points there's a pile of commands you can mess with. Some dangerous and some simple. I like the simple ones. They keep me out of trouble. "show" is one of them. Pretty obvious what it wants. At the prompt key in "show" after you see
netsh interface tcp ipv4> (You remembered to Enter before, ri....*OUCH* stop that!)
netsh interface tpc ipv4>show
The following commands are available:
Commands inherited from the netsh context:
show alias - Lists all defined aliases.
show helper - Lists all the top-level helpers.
show mode - Shows the current mode.
Commands in this context:
show addresses - Shows IP address configurations.
show compartments - Shows compartment parameters.
show config - Displays IP address and additional info
show destinationcache - Shows destination cache entries.
show dnsservers - Displays the DNS server addresses.
show dynamicportrange - Shows dynamic port range configu
show global - Shows global configuration parameters.
show icmpstats - Displays ICMP statistics.
show interfaces - Shows interface parameters.
show ipaddresses - Shows current IP addresses.
show ipnettomedia - Displays IP net-to-media mappings.
show ipstats - Displays IP statistics.
show joins - Displays multicast groups joined.
show neighbors - Shows neighbor cache entries.
show offload - Displays the offload information.
show route - Shows route table entries.
show subinterfaces - Shows subinterface parameters.
show tcpconnections - Displays TCP connections.
show tcpstats - Displays TCP statistics.
show udpconnections - Displays UDP connections.
show udpstats - Displays UDP statistics.
show winsservers - Displays the WINS server addresses.
My goodness this is pile more. Well in this case I'm interesting in viewing my current IP address and how it's been setup. And believe it or not, it's obvious!
netsh interface tcp ipv4>show addresses
In my case I get these off my test machine.
Configuration for interface "Local Area Connection"
DHCP enabled: No
IP Address: 10.0.0.49
Subnet Prefix: 10.0.0.0/24 (mask 255.255.255.0)
Default Gateway: 10.0.0.1
Gateway Metric: 256
Configuration for interface "Loopback Pseudo-Interface 1"
DHCP enabled: No
IP Address: 127.0.0.1
Subnet Prefix: 127.0.0.0/8 (mask 255.0.0.0)
So here's where you get useful information about the IP address and gateway typing "show dnsservers" in this context gets you a list of DNS Servers in use, "show interfaces" will show you the descriptive name of all your network cards. This comes in handy with the next step. SETTING your IP address.
netsh interface tcp ipv4>set address
If you just typed "set" by itself it would show you all the things you can "set". Right now I just want to "SET" my ip address so I can do something with this. Keying "set address" by itself will give me more instructions. But I want to "SET" my IP address before my coffee gets cold.
netsh interface tcp ipv4>set address name="Local Area Connection" source=static 192.168.1.20 255.255.255.0 192.168.1.1
Ding. Now I have the IP address changed to 192.168.1.20
Now if you want to forget how to do all this in the future, because you're lazy; like me. Get out your copy command and paste that whole line into notepad and save it as a BAT or CMD file. Then just edit the IP address later for the next machine. Take out the ">" from the line of course so it reads.
netsh interface tcp ipv4 set address name="Local Area Connection" source=static 192.168.1.20 255.255.255.0 192.168.1.1
But what if the name of the Lan Connection was "Server Connection" or more importantly what if I have SEVERAL network cards? the "show interfaces" lists them all by name. You can modify the section that says "Local Area Connection" with whatever names are assigned to your card.
There's a lot more power to the command line than just setting an IP address, like allowing firewall exclusions for example. The great part is. It's not bandwidth intensive. Copy, paste, run.
Next time we'll touch on other commands like how to rename your computer or maybe join it to a domain.
Until next time
The EnergizedTech -
Dedication and Inspiration creating the new Generation