r/networking • u/DavisTasar Drunk Infrastructure Automation Dude • May 15 '13
Mod Post: Community Question of the Week
Hey /r/networking;
So here we are, another Wednesday! Last week we talked about your biggest oops. This week, let's talk about something a wee bit different:
Question #5: What is your best little trick? Something that you know that's saved your butt a few times that others could benefit from?
24
Upvotes
5
u/jbennefield I made my own flair! May 15 '13
archive path tftp://address/$h-
write-memory
time-period 10080
file prompt quiet
this auto backs up your config you can lower the time-period if its a device you touch a lot and it will archive on its own Its saved us a few times on access switches that have gone belly up find old config upload it to replacement switch and run
5
u/[deleted] May 16 '13 edited May 16 '13
Oh yeah I forgot another one - apply-groups in Junos.
Let's say for example on an SRX you need to log all traffic for every single security policy on the firewall. If you have hundreds or thousands of policies doing this manually is a huge pain in the rear. By utilizing apply-groups and show | display inheritance you can see the changes, and which apply-group was applied the additional configuration. This is an excellent way to automate mundane settings in the junos configuration, or to prevent newbies from making mistakes on policies.
The configuration gets adjusted to look like this: show security policies | display inheritance
12
u/kunstlinger whatever May 15 '13
on a cisco device that I may have to make a change where I lose connectivity and would like to reboot if things don't go well.
Before I do my planned changes, I issue
Then if things are successful, I cancel the reload
Saved me during some remote IOS upgrades when things didn't go exactly to plan. Not something I would consider a "best practice" in most scenarios, but given the right environment, this is a useful and handy trick.
article: http://tekcert.com/blog/2010/10/19/cisco-reload-command
8
u/[deleted] May 15 '13
diffGot an issue on a box? Take a
sh techor platform equivalent, reproduce issue, gather another output, run through diff.Seriously, helps you get to the bottom of things fast.
8
u/[deleted] May 15 '13
Junos has a nifty trick called commit confirmed that gives you a rollback in 5 minutes if you do not perform a second commit after the initial commit. What some may not know if you can set the time to as low as 1 minute if you add the time behind the confirmed. For example commit confirmed 1 will set the rollback time to 1 minute instead of the default 5 minutes.
Also, you can use configure exclusive in order to lock the candidate configuration to only you. This prevents others from editing the candidate configuration and interfering with each other.
If you use configure private (the default for SRX clusters) that will allow you to make changes to a standalone candidate configuration. This is the nicer way to ensure other admin's changes aren't committed while you are editing a candidate configuration without locking them out entirely.
6
u/totallygeek I write code May 15 '13
Not really a trick, but more of a public service announcement. Consider working within screen or tmux for everything you do. Not only can you disengage your session and return to it from another location, but you can log what work is performed (a life saver during automation executions run amok).
5
u/KantLockeMeIn ex-Cisco Geek May 15 '13
tclsh. You can run a TCL script directly on an IOS or IOS-XE device... and the script you execute can be downloaded on the fly via tftp. So you can have a repository of scripts which are helpful in configuring or troubleshooting on a centralized tftp server, and call them from any of your routers.
One example would be in configuring QoS. You can create a generic global config template for class-maps and policy-maps and ACLs... push them to all devices. But interface level config, you can have a TCL script apply the right policy map to the right type of interface. Remotely execute the TCL script (rsh or ssh) and you can consistently deploy global and interface level configs in one shot.
4
u/Ace417 Broken Network Jack May 15 '13
Secondary ip addresses on an interface. We are moving from a single vlan to multiple in our remote sites. I am dumping a secondary address on the new vlan with the old address that way it can be slowly migrated off. It's quick and dirty.
Just dump all the ports to that vlan and move at your leisure.
4
u/disgruntled_pedant May 15 '13
I do a lot of output scripting, so:
Cisco ASA VPN -- "show vpn-sessiondb full [remote/svc]" will print your output in vertical-bar-separated lines, which is so nice for grepping and splitting.
Juniper SRX -- "show security policies from-zone $fromzone to-zone $tozone detail" will resolve all your address-book and application entries.
Cisco ASA, you can disable or change the level of specific log messages. I love this so much.
Cisco ASA, I use a LOT of network-objects to make ACLs and their crypto-maps easy to read.
And in general, back. your. stuff. up. Want to know the last time you used a particular VLAN number or what an interface description used to be? Grep for it. Want to know what change was made in the last day to produce weird things? Diff for it. Device died and you need to quickly configure a replacement? Paste it.
My last trick, logwatch. There's a cisco module for logwatch (which doesn't work in rsyslogd or whatever my sysadmin uses now, so I had to dump the code to a different format) that you can customize to ignore, group, and count your log messages. So often when I go to a security-focused conference, a speaker will say "How many of you actually look at your logs every morning?" I do. I look at my logs every morning. I get an email that's well-formatted, pre-parsed, and easy to read.
7
u/networkjedi May 15 '13
cisco router doing domain lookup, Ctrl+Shift+6 will cancel the lookup, or break any other command that you put in that's running.
3
u/[deleted] May 15 '13
I'm sure this isn't news to most of you but Cisco switches and routers can do pings with a range of sizes which helps immeasurably with diagnosing MTU issues. You can also specify source interface (as you can in traceroute as well).
Eg:
I generally start with a big sweep interval and then start narrowing it down.
3
u/kewlness May 15 '13
Definitely configure archive. I have several L3 devices which are updated with customer data automagically from a process but when the process breaks, it can really foobar the router. Thankfully, with configure archive on the SUP, I can roll back a change very quickly.
Also, while not saving my butt per se, the do command is one of the most useful commands not documented when in configure mode (for example: do show running-config | include ip route.*255.0).
3
u/maced129 May 16 '13
Traceroute mac command can come in handy sometimes when for example, you only know the IP of a workstation and you need to find what port and what switch it is connected to quickly. Helped me once or twice. Here is what it looks like (in Cisco's example they used source and destination MACs, but you can do it by source and destination IPs). In the example you can see the destination was found on Fa0/1 on [WS-C3550-24] (2.2.2.2).
Router# traceroute mac 0000.0201.0601 0000.0201.0201
Source 0000.0201.0601 found on con6[WS-C2950G-24-EI] (2.2.6.6)
con6 (2.2.6.6) :Fa0/1 => Fa0/3
con5 (2.2.5.5 ) : Fa0/3 => Gi0/1
con1 (2.2.1.1 ) : Gi0/1 => Gi0/2
con2 (2.2.2.2 ) : Gi0/2 => Fa0/1
Destination 0000.0201.0201 found on con2[WS-C3550-24] (2.2.2.2)
Layer 2 trace completed
2
u/[deleted] May 15 '13
Want to immediately gauge packet loss? Try ping -c 100 -f <HOST> to a destination host. I typically pick 4.2.2.1 or 8.8.8.8 since neither rate limit ICMP (and I will also add that rate limiting is almost useless with 100/1000 Mbps connectivity).
Do not ping -f routers unless they're intermediate hops from a traceroute. ICMP is handled by router control planes and are typically processed by the so-called slow path. So often it is deprioritized and doesn't provide accurate results (and more often than not rate-limited).
2
u/yeaiforgot May 15 '13
I log my SecureCRT sessions and its pretty useful when I want to review a change or some output for some previous date. Using grep with it makes life easier.
3
u/tonsofpcs Multicast for Broadcast May 15 '13
Stop using traceroute for everything. Learn to use mtr.
Seriously, how do so few people know of this tool?
1
u/pegun CCIE R&S, Security Wr, CISSP Sep 25 '13
/ in IOS when you run a show run will allow you to filter down to a given keyword. So if you know what you're looking for, but perhaps need to see it at multiple places within the config (which | sec, b or i can't get you efficiently), do a show run <cr> / crypto-map will take you to the first occurrence of crypto-map...then the next...