Access-list mask or wildcard

G’day all, today I was messing around with access-list.  And after getting my head around the weird subnets of rfc1918. Weird as in an A-class (/8) is reserved in A-space, B-class (/16) in reserved in C-space, and for the B-space has a /12 is reserved. Nothing is standard in the world of standards.

But that on a side-note. The whole rfc1918 got me distracted. So when I started creating the access-list, I mistakenly used the subnet mask instead of the wildcard.

First I made the access-list using subnet masks.

ISP1-R1(config)#ip access-list extended rfc1918-wrong
ISP1-R1(config-ext-nacl)#permit ip 10.0.0.0 255.0.0.0 any
ISP1-R1(config-ext-nacl)#permit ip 172.16.0.0 255.240.0.0 any
ISP1-R1(config-ext-nacl)#permit ip 192.168.0.0 255.255.255.0 any
ISP1-R1(config-ext-nacl)#deny ip any any
ISP1-R1(config-ext-nacl)#exit

Next I made the access-list using wild cards.

ISP1-R1(config)#ip access-list ex rfc1918-right
ISP1-R1(config-ext-nacl)#permit ip 10.0.0.0 0.255.255.255 any
ISP1-R1(config-ext-nacl)#permit ip 172.16.0.0 0.15.255.255 any
ISP1-R1(config-ext-nacl)#permit ip 192.168.0.0 0.0.255.255 any
ISP1-R1(config-ext-nacl)#deny ip any any

I check the things that I do in a network. I think its a good habit and somebodies health might depend on it.

ISP1-R1#sh access-lists
Extended IP access list rfc1918-wrong
10 permit ip 0.0.0.0 255.0.0.0 any
20 permit ip 0.0.0.0 255.240.0.0 any
30 permit ip 0.0.0.0 255.255.255.0 any
40 deny ip any any
Extended IP access list rfc1918-right
10 permit ip 10.0.0.0 0.255.255.255 any
20 permit ip 172.16.0.0 0.15.255.255 any
30 permit ip 192.168.0.0 0.0.255.255 any
40 deny ip any any

You see that the access-list made using subnet mask are completely borked.

The moral of the story is as follows;

  • always check what you have configured.
  • Use subnet mask to assign ip addresses to interfaces ans wildcards for accesslists.

 

Advertisements
Posted in CCNP | Tagged , , , ,

Juniper filters

In the networking world a multitude of vendors are present. And each of them have their magnificent features  but also their quirks. And one of the quirks, for the network vendors in general, is that terminology is not uniform.

Where Cisco likes to talk about Access-Control List or ACL for short Juniper likes to talk about filters. Juniper filters are awesome. Juniper likes to arrange information a tree-like structure. This enables Juniper for future changes in software approach.

Cisco has standard access-list, the down-side; modification can not be done. Deletion of one ACE is not possible.  The entire ACL has to be removed.

A slight improvement are extended access-lists. Every ACE has a number associated with it. And using some ip access-list resequence magic you can make some room to insert ACE’s.

This hassle is not known to Juniper engineers.

Simply create a access-list ehm …. filter

set firewall family inet filter generic-filter term discard then discard

This filter simply, forwards every packet to the great bit-bucket in the sky.

If you want to allow traffic from you lan towards webservers you add the following;

set firewall family inet filter generic-filter term web_lan from source-address 10.0.0.0/8
set firewall family inet filter generic-filter term web_lan from protocol tcp
set firewall family inet filter generic-filter term web_lan from destination-port 80
set firewall family inet filter generic-filter term web_lan then accept

Now you have two terms within the “generic-filter”

show configuration firewall
family inet {
    filter generic-filter {    
        term discard {
            then {
                discard;
            }
        }
        term web_lan {
            from {
                source-address {
                    10.0.0.0/8;   
                }
                protocol tcp;
                destination-port 80;
            }
            then accept;
        }
    }

If you leave it this way traffic to the webservers are discarded instead of allowed. This is where Juniper added some pretty awesome magic;just shuffle the term to a place where is fits best.

insert firewall family inet filter generic-filter term web_lan before term discard

Of course you need to address some more issues like established traffic etc.

But this is how Juniper addresses filters. And there are a whole lot more things you can manage with filters. You can create a variables , and when a condition is met the counter is raised by the value you like.  Variable is readable in the context of show firewall.

Today my first steps in Juniper filtering. An awesome experience.

Posted in Juniper

Be micro-ambitious

I love to read.  And one of my favorite topics is how information is stored in the brain.  How the brain learns.  What interval of learning is most effective an how goal setting works. 

A couple of books clearly state.  Do not set your goal too high.  But better set a lot of smaller goals.  In this way you can tick off many boxes whilst reaching your ultimate goal.  So be micro-ambitious instead of being ambitious.  

Posted in Lifehacking | Tagged , ,

Juniper SRX 110

This week I bought an Juniper SRX 110. This device will help me to get more acquainted with the Junos cli structure.  From a Cisco perspective this box is slightly wider than a Cisco 8xx series router. But maintaining 1U height.

IMG_20170706_010630This box will sit in the utilities closet when I find time to tinker around with this new toy.

 

 

Posted in Juniper | Tagged , ,

Policy Based Routing

Policy-Based routing is a neat trick to tweak traffic streams.

For Policy Based Routing to work you will the following;
– Define traffic stream in an access-list.
– Write down a policy.
– Determine the inbound interface.

First use an ACL to define the traffic streams.
You can use standard, extended or named access-list.

In this example traffic sourced from 1.1.1.1 and 2.2.2.2 destined for 3.3.3.3 is defined in ACL 100.

access-list 100 permit ip host 1.1.1.1 host 3.3.3.3
access-list 100 permit ip host 2.2.2.2 host 3.3.3.3

Next you will to define the policy.
If you want to want set the next hop for this traffic stream. You have to do;

route-map just-a-name permit 10
 match ip address 100
 set ip default next-hop 10.10.10.20

Once you have formulated the traffic stream and the tweak all you have to do is apply it to an interface.

interface Ethernet0/0
 ip address 100.100.100.1 255.255.255.0
 ip policy route-map just-a-name

Be careful : the name of the route-map is CaSe senSitive.

Why is this a great little trick; you can use policy based routing to prevent asymetric routing in a HSRP setup. Or you can send specific traffic towards an IDS / firewall /deep packet inspection device. Or simply send traffic to an black-hole in case of unwanted/malicious traffic.

 

Posted in CCNP | Tagged ,

Error-Disable

When a network port encounters an error. This port is automatically shutdown to ensure network stability. When error-disable is enabled.

The predefined error are as follows;

arp-inspection 
bpduguard
channel-misconfig
dhcp-rate-limit              
gbic-invalid                 
l2ptguard                  
link-flap
mac-limit
link-monitor-failure
loopback
oam-remote-failure
pagp-flap
port-mode-failure
psecure-violation
security-violation
sfp-config-mismatch
storm-control
udld
vmps

Primary function of error-disable is fault detection. Secondary you can set up recovery, per predefined error.  This can be done by ;

errdisable recovery cause

Be sure to set the recovery interval to your specific needs;

errdisable recovery interval 60

Whenever  a port is disabled due to an error-disable condition you should see something like ;

somerouter#show interface GigabitEthernet1/6
GigabitEthernet1/6 is down, line protocol is down (err-disabled)
--//output omitted for brevity//--

Interesting to see that the port is in down/down status with an err-disabled condition.

If you do not resolve the root cause the log will be flooded with

Jan 10 08:51:35.074 CET: %PM-4-ERR_RECOVER: Attempting to recover from link-flap err-disable state on Gi1/6
Jan 10 08:51:37.179 CETT: %PM-4-ERR_DISABLE: link-flap error detected on Gi1/6, putting Gi1/6 in err-disable state

To resolve the problme one has to know the root cause, for this you’ll have to issue the command “show errdisable recovery”. First you see a list of errors where recovery is enabled, or disabled. (See column ‘Timer Status’)

somerouter#sh errdisable recovery
ErrDisable Reason            Timer Status
-----------------            --------------
arp-inspection               Disabled
bpduguard                    Enabled
channel-misconfig            Enabled
dhcp-rate-limit              Disabled
gbic-invalid                 Enabled
l2ptguard                    Disabled
link-flap                    Enabled          
mac-limit                    Disabled
link-monitor-failure         Disabled
loopback                     Disabled
oam-remote-failure           Disabled
pagp-flap                    Enabled
port-mode-failure            Disabled
psecure-violation            Enabled
security-violation           Enabled
sfp-config-mismatch          Disabled
storm-control                Disabled
udld                         Enabled
vmps                         Enabled

Timer interval: 60 seconds                     

Interfaces that will be enabled at the next timeout:

Interface       Errdisable reason       Time left(sec)
---------       -----------------       --------------
Gi1/6                 link-flap           47

Root cause for the problem with interface Gi1/6 lies in link-flap. This is somewhat cryptic but will give you an idea where to find the solution.

Possible root causes are;
dodgy cabling
faulty optics (sfp/gbic)
wrong speed/duplex settings
hardware loop

In this particular case I suspected the speed/duplex settings.

somerouter(config-if)#speed nonegotiate
somerouter(config-if)#shut
somerouter(config-if)#no shut
somerouter(config-if)#
Jan 10 11:20:31.589 CET: %LINK-5-CHANGED: Interface GigabitEthernet1/6, changed state to administratively down
somerouter(config-if)#
Jan 10 11:20:33.703 CET: %LINK-3-UPDOWN: Interface GigabitEthernet1/6, changed state to up
somerouter(config-if)#
Jan 10 11:20:33.712 CET: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/6, changed state to up

Link was forced down and up to get rid of the error-disable condition.
Terminal monitor was turned on to instantly see what is going on.
Logging tells me that the port is admin down and that changed to up.
Et voilà, line protocol is also changed to up.

Root cause found and resolved.

Posted in CCNP | Tagged , ,

SSH error on cisco router

Enabling SSH on a Cisco router is not enough to guarantee SSH is working.
Enabling ssh version 2.0 on a routers is as straight forward as;.

>ip ssh version 1-2

I surely recommend the use of version 2, because ssh v1 has a bug which allows root access.

Anyhow… ssh needs some sort of encryption to work. In other words create a crypto key.

host(config)#crypto key generate rsa modulus 2048
The name for the keys will be: host.somenetwork.com
% The key modulus size is 2048 bits
% Generating 2048 bit RSA keys, keys will be non-exportable...
[OK] (elapsed time was 2 seconds)
host(config)#
Nov  5 14:17:17.240 UTC: %SSH-5-ENABLED: SSH 2.0 has been enabled

The good thing is the crypto key is not saved in config. The bad thing is, whenever you commission a router and forget to create the crypto key it can cost you some time in troubleshooting. Worst case you have to travel on-site to create the crypro key.

By the way, make sure you enable ssh on the VTY ports and if applicable deny telnet input.

line vty 0 15 
transport input ssh
no transport input telnet

And create an access-list and apply it to the VTY ports.

FYI: SSH enables encrypted CLI access towards a host. And the crypto key validates the host communication i.e. detection of a man-in-the-middle attack.

Posted in CCNP