Mac – Set your static IP address fast!

A quick update on the last post – but for OS X!

The OS X terminal is more comfortable than the Windows CLI for route/switch guys like me. Here’s how I make quick IP changes in OS X.

You can create command aliases just like in Cisco IOS by adding them to the profile that terminal loads when you open the app. Just open terminal, and type “open .profile”. Here I’ve done just that, and you can see my terminal profile:

profile Sublime Text, Today at 10.21.49 AM

If you’ve never messed with the terminal profile, it will likely be empty. But the basic syntax is straightforward. Save the file and close/reopen terminal for the aliases to become available.

Here are a couple of my examples:

  • “setair” will statically set my Wi-Fi adapter address
  • “setethdhcp” will revert my ethernet NIC to DHCP
  • “shair” is like ipconfig in Windows, or a simpler version of ifconfig for OS X:

shair— -bash — 139×39 Terminal, Today at 10.26.43 AM.png

Note that any commands running SUDO will prompt you for your elevated password.

Set your static IP address fast!

Hello! Sorry for the radio silence – I have been a little sidetracked from welcoming my second daughter into the world on March 21st! Lack of sleep and going back to work this week are my excuses for a little blogging break – I’m not sure my ramblings would have made much sense anyhow…

But I was inspired by this tweet today:

John here wrote a really cool post about some of the ways he uses the netsh command in the Windows CLI. I knew about the “netsh WLAN show …” commands already, but John has demonstrated a neat way to monitor roaming with a simple loop. It’s elegant because it’s simple and works.

This got me thinking about a little trick I’ve been using for years now with netsh to avoid a certain pain in the arse I would otherwise be dealing with in Windows. Maybe I can help someone with my trick like John helped me with his.

I’m a CLI guy – if you’re a Cisco Route/Switch person, you know why. Heck, I try to avoid taking my hands off of the keyboard as much as possible.

If there is one thing I do a lot in Windows, it’s set static IP addresses on my NICs. And then set them back to DHCP. Sometimes several times a day.

Worse yet, when I need to bootstrap a router/switch/controller/network voodoo box, 9 times out of 10, I’m using wifi to remain internet connected while using my wired NIC to connect to the new unit – a lot of which provide DHCP out of the box. The problem with this is that my Windows wired NIC is preferred and I’m getting a default gateway from the DHCP server on the box I’m bootstrapping, even though that’s a dead end. There goes my internet until I set a static IP without a gateway on my wired NIC.

The default work flow to change the IP settings on your NIC is terrible (Windows 8.1 example):

Start > Control Panel > Network and Sharing Centre > Change Adapter Settings > Right-click adapter > Properties > TCP/IPv4 > Properties: Set your IP/Mask/Gateway if required > OK.

And don’t forget the three windows you now have to close. Then do it all over again to set back to DHCP. Sure, there are some shortcuts you can use to this process, but I still have nightmares about this. Enough complaining – here’s what I do.

First, I renamed my NICs to “wired” and “wireless” in the “network connections” window (after “Change Adapter Settings” in the work flow above). Just right click and rename, it won’t hurt anything and makes it so much easier to read CLI output.

Then I write myself a little script in notepad:

@ECHO off
set /p ipadd=Enter address and mask, press enter:
netsh interf ip set add wireless static %ipadd%
timeout /t 5
goto end

Then I save it as a batch file called “Wireless Static.bat”. But wait, there’s more…

I right-click that sucker and choose “create shortcut”, which creates a “Wireless Static.bat – shortcut” file in the same folder. I rename it to “Wireless Static”, then right-click again and go to the file properties – here’s the magic:

CMD Batch file

The “Target” field will have the full path to the file. I prepend the path to the cmd.exe executable like so:

C:\Windows\System32\cmd.exe /c “full path to script”, then hit “Ok”. Now I have two files, the original batch file, and a shortcut with the CMD icon:

IP bat and shortcut

That CMD shortcut right there can be pinned to the Start page or Taskbar – the batch file can’t.

Still with me? Here’s the result! I pin mine to the Start page, so I hit the Windows key, and click the shortcut I want.

Start Page.png

Here’s the prompt, after I slap in my new static IP. The format is IP address, Mask, Gateway (if required), with a space between each.

Enter Address

I press enter, the script runs the netsh command, and counts down for 5 seconds before running an ipconfig to verify the result (I was remote desktop-ed to my Windows notebook when I took the screenshots, so I erased the wireless NIC addressing output to avoid confusion).

Static Wait.png

Finally, the “pause” parameter in the batch file leaves the output there for me to look at until I’m ready to dismiss it with a tap of the “Enter” key.

Three buttons, one click, and typing the addressing. YES.

You can do another script for returning to DHCP. I’ve got separate shortcuts for static and DHCP for each NIC, but you can modify the batch file to make the user type the NIC name and put it into the netsh command as well so you can use one shortcut for any NIC, if you prefer (this is where it helps to rename the NICs).

Here attached are my basic batch files for anyone who wants to try them out. PDF because wordpress won’t allow me to attach text files.

IP Static


Wireless Static

Wireless DHCP


ESS Easter Eggs

I noticed some tongue in cheek progress bar comments in the the ESS CAD import dialog, so I took a few screengrabs. Here are the ones that were on screen long enough to catch:

Phase 4

Phase 5

Phase 6

Phase 9

Phase 10

ESS decides to stay in the Matrix…

Phase 11

Phase 13

I wonder who Stew is.

Phase 15


Phase 16

Phase 20

Phase 23

Phase 26

There are some complex calculations involved in designing RF.

Phase 30

Phase 31

Phase 34

It’s always fun to see software engineers with a sense of humour 🙂


Howdy. I am a network engineer with a wifi hobby. I mean (cue Keanu) I know Kung-fu: routing and switching, firewalls, and data centre stuff, but I know wifi is an entirely different beast, and my wireless Kung-fu (henceforth “Wi-fu”) is weak.

Wifi has a well known community on the web. In the words of Keith Parsons: “You HAVE to be on Twitter”. I’ve been a spectator in this community via Twitter for a while, and I’ve learned TONS. But I was recently fortunate to meet some people who are a big deal in wifi (including the guy who actually wrote the book that I used to pass the CWNA certification); and I was able to experience the wifi community first hand.

While it was definitely intimidating at first to be in same room as these guys (the Bruce Lee, Mr Miyagi, and Chuck Norris of wifi), the community has earned a reputation for being inclusive and these black belts were omgsupercoooool ambassadors. Whilst they somewhat mocked my great white north heritage, it was no biggie for a few of us noobs to sit at the cool kids’ table for lunch and share a few drinks after class (eh!).

Which is why Im not surprised that I’m here trying valiantly (VALIANTLY) to not type “Dear Diary…”. The wifi community is also big on contributing to said community, so I was quickly asked about my blog. Everyone in wifi has a blog, so I was a hoser because I didn’t (extrapolation mine alone and tongue in cheek :P).

So now I’m a hoser with a blog. “Net Gain” was the most clever play on wired and wireless networking I could come up with in ten minutes.

Here’s to hoping that either:

-I remain relatively anonymous and therefore continue to embarrass myself to my direct clients and colleagues.


-Someone learns something from this. My apprentice seems to be doing alright, but who knows if that will translate into a larger scale experiment.

Subsequent posts to be networking and wifi-centric. Probably rant-y and self-deprecating!