I need help working with router config backup database. I need to get a list of interfaces that don't have vrf or shutdown in their configuration.
I get the list of all interfaces config passing the config file through awk '/^interface/,/!/'. This gives me the output below:
interface TenGigE0/3/0/0
description
service-policy output QOS
ipv4 mtu 1500
ipv4 address 13.24.15.3 255.255.255.252
carrier-delay up 3000 down 0
load-interval 30
dampening
!
interface TenGigE0/3/0/1
description Link To
!
interface TenGigE0/3/0/1.302
description
vrf 1671
ipv4 address 13.24.14.11 255.255.255.254
encapsulation dot1q 302
Now, i am stuck trying to exclude the interfaces that contain vrf line. What i was trying to do is to grep for vrf, and when there is a match, remove the line that contains the word "interface" above. Unfortunately with no luck. Maybe someone has a more sophisticated solution.
If you have the structured records awk can solve this problem. Given your intermediate file
2$ awk 'BEGIN{RS=ORS="!\n"} !/vrf/' interface
will print the records without "vrf"
interface TenGigE0/3/0/0
description
service-policy output QOS
ipv4 mtu 1500
ipv4 address 13.24.15.3 255.255.255.252
carrier-delay up 3000 down 0
load-interval 30
dampening
!
interface TenGigE0/3/0/1
description Link To
!
Related
I have developed a web scrape software for personal use. Now I need to change my IP address in every 30 seconds for resist block. What is the best way to change IP address in every 30 seconds?
Thank You.
Use proxy plugins that can help you do this.
If you are on UNIX system, you can try this:
Create an ip.sh file with content below, replacing eth0 by your network interface if necessary and by the 3 first numbers of your network's IP address (e.g. 192.168.1)
chmod 700 ip.sh
./ip.sh (use sudo if you're not using the administrator account)
ip.sh file:
#!/bin/bash
index=2
while :
do
ifconfig eth0 <IP>.${index} netmask 255.255.255.0 up
index=$((index+1))
if [ "$index" -gt "254" ]; then
index=2
fi
sleep 30
done
I know this code works on Windows, but how do I get workable code executable on MacOS?
netsh -c interface ipv4 add neighbors "(connection name)" "(router
address)" "(mac address)" store=persistent
Any suggestions please...
try typing "man arp" into the terminal. Something like this might work :
arp -s hostname ether_addr
Create an ARP entry for the host called hostname with the Ethernet address ether_addr. The Ethernet address is
given as six hex bytes separated by colons. The entry will be permanent unless the word temp is given in the
command. If the word pub is given, the entry will be ``published''; i.e., this system will act as an ARP server,
responding to requests for hostname even though the host address is not its own. In this case the ether_addr can
be given as auto in which case the interfaces on this host will be examined, and if one of them is found to
occupy the same subnet, its Ethernet address will be used. If the only keyword is also specified, this will cre-
ate a ``published (proxy only)'' entry. This type of entry is created automatically if arp detects that a rout-
ing table entry for hostname already exists.
I am a newbie to logstash / grok patterns.
In my logfile i have a line in this format as below:
::ffff:172.19.7.180 - - [10/Oct/2016:06:40:26 +0000] 1 "GET /authenticator/users HTTP/1.1" 200 7369
When I try to use a simple IP pattern matching %{IP}, using grok constructor, it shows only partial match:
after match: .19.7.180 - - [10/Oct/2016:06:33:58 +0000] 1 "POST /authenticator/searchUsers HTTP/1.1" 200 280
So, only a part of the ip address matched, as the portion 'after match' still shows remaining portion of ip address.
Queries:
1. What is this format of IP address ::ffff:172.19.7.180?
2. How to resolve this issue, to ensure IP address is correctly parsed?
BTW, I am using nodejs middleware morgan logger, which is printing IP address in this format.
Note that the log contains both IPv4 and IPv6 addresses separated by a colon, so the correct pattern you need to use is the following one:
%{IPV6:ipv6}:%{IPV4:ipv4}
Then in your event you'll have two fields:
"ipv6" => "::ffff"
"ipv4" => "172.19.7.180"
This will work until this issue is resolved.
These IP addresses are in the IPv4-Embedded IPv6 Format and the %{IP} doesn't match it. The only way to go is to either use %{DATA} or write your own regex.
I've got a text file with a bunch of IPv4 addresses, and I'd like to know the hostname of each one in order to know if they are tor addresses. Is there a simple script that can help me to do that ?
You can loop using dig:
#!/bin/bash
while read line
do
dig -x "$line" +short
done
Then given IPs 1 per line, you can run something like ./reverse.sh < addrs.txt.
Caveats: DNS is not a 1-to-1 mapping, and reverse DNS is somewhat less reliable than forward DNS.
I'm currently writing a script to generate a report from cisco configuration for audit purposes. Using 'grep' command, I was able to successfully capture the global configurations.
But the challenge is doing it per interface. For example, I want to know which interfaces have these lines 'no ip redirects', 'no ip unreachables', etc. How can I accomplish this in bash?
Thank you in advance!
This can not be done easy with grep, but awk handle this:
cat file
!
interface GigabitEthernet0/13
description Server_32_main
spanning-tree portfast
no ip redirects
!
interface GigabitEthernet0/14
description Server_32_log
switchport access vlan 666
spanning-tree portfast
!
interface GigabitEthernet0/15
description UPS_20
spanning-tree portfast
!
As you see, each group is separated by !, so we use that to separate each record.
To get only interface name do like this:
awk -v RS="!" -F"\n" '/no ip redirects/ {print $2}' file
interface GigabitEthernet0/13
To get interface config do:
awk -v RS="!" '/no ip redirects/' file
interface GigabitEthernet0/13
description Server_32_main
spanning-tree portfast
no ip redirects
To get more patterns in one go:
awk -v RS="!" '/no ip redirects/ || /no ip unreachables/' file