Sunday, October 20, 2013

why friends don't let friends, buy cisco ASA part#3 "A quick glance at cisco support for dynamic routing within a context "

Finally cisco has started including dynamic routing within a context since 9.1.2. The demonstration here, are  done 9.1.3 version and on a ASA5558-X




If you're familiar with the cisco ASA lineup, then the enabling of multi-context-mode in the past, only allowed for static routing. This lack of  dynamic-routing feature,  has been available in the juniper & fortinet based firewalls for a while now and within the equivalent multi-mode  ( virtual routers and vdoms )

Cisco within the ASA5558-X series, has just now started supporting  EIGRP or OSPF  as indicated here on a multi-context firewall ;



NOTE:  So that means no rip (v1/v2 ) or BGP


You  will also find out only  2 ospf  process can be started in the one context. If you try to start more than two process, you will quickly discover the following error


Playing around with the admin context showed me you can only start one  EIGRP process;


And finally, we can not enable any ipv6 dynamic routing.The ipv6 router process as seen here in a non multi-context mode firewall ;



Is flatout not available in a multi-context ASA;



One other thing you might want to considered when design routing for your ASA, you need to be aware of resources limits. The cmd " show resource usage context 'context-name' resource routes
" will display your route limits and usages.

note: the admin context by default is not limited in any shape or fashion;



note: And I'm not 100% sure if the limits set are for both;   ipv4 and ipv6 routes & regardless if you running a dynamic routing.


keyPoints and take aways;

1:  support for only EIGRP or OSPF dynamic protocols
2:  can run 2 instances of  OSPF in  single context
3:  but can only run 1 instances of EIGRP per context
4:  You can also run a  1of each (  OSPF+EIRGP process  ) per context
5:  no ipv6 dynamic routing support
6:  No support for the other open routing protocols like RIP or BGP



Ken Felix
Freelance Network / Security Engineer
kfelix  ----a---t---socpuppets ---d---o---t---com

     ^      ^
=(  @   @ )=
          o
       /     \



Thursday, October 17, 2013

named-server logging channels & categories

Logging DNS  events , is a challenge,  but ISC bind makes it easy with channels & categories.  Take this snippet from a named.conf on a ccTLD server that I'm working on;


//#################################

logging{
  channel simple_log {
    severity info;
    syslog local7;
    print-time yes;
    print-severity yes;
    print-category yes;

   
  };

    channel null_log {
    severity info;
    null;
    print-time yes;
    print-severity yes;
    print-category yes;
  };

  category config {
    simple_log;
  };
  category network {
    simple_log;
  };
  category notify {
    simple_log;
  };
  category database {
    simple_log;
  };
  category xfer-in {
    simple_log;
  };
  category xfer-out {
    simple_log;
  };


  category client {
    null_log;
  };
 
  category default {
    simple_log;
  };

  category security {
    null_log;
  };

  category lame-servers {
    null_log;
  };

  category edns-disabled {
    null_log;
  };
 
  category dnssec  { null_log; };

  category resolver  { null_log; };
 
  category update-security { null_log; };

};



Okay you see 2 channels named simple and null and a few of "nulls" at the bottom?

Okay what I'm doing here is apply these categories ahead of time but directing the output to my null logging-channel, which is basically like a dev-null.

If for example, I  start to deploy DNSSEC, I can quickly change the  null_log to my simple_log, restart named via "rndc reload" and start gathering log data. After I 'm finish, I can leave or revert back to null_log. This is a simple approach for logging imho.


For client queries, I can toggle this feature via rndc and querylog. It's easy todo and DOES NOT NEED A RESTART/RELOAD of named.

Here's me toggling it on using the utility  rndc



and when  you disable it,  your primary logfile and rndc status should show it being off. Take heed of the client queries in the tail of my syslog file.




I could have even directed the output of the client queries to yet another destination.


I hope the above examples, give you a insight into just how powerful DNS & ISCbind name-server, and when it comes to logging.


A few key-points to remember;

1: on client  queries and logging, don't enable it forever, since you could easy consume your diskspace on the localhost or remote-syslog server if you run it on a very busy TLD or authoritative name-server for to long of a time

2: if you log alot of categories, your dns-server could see a higher CPU and IO impact

3: if you log via remote-syslog to an external logging source, keep the above 2 points and the network traffic (udp/tcp depending on how your logging )

4: rsyslog on linux can flake out with heavy log datagrams when using udp protocols

5: a better solution is a commerical logging host for heavy TLD or ISP dns-servers


Some of the name-servers that I'm  currently working on,  handles anywhere from  50-100k queries per minute or more. So that's a lot of client queries.

Logging on some of these servers,  can  easily become over 100-200megs per-day. I have one dedicate host for just one primary name-server & that use a 1.5tg external drive for logging against  400+ domains.

IO activity is always high on this machine for the obvious reasons :)



Ken Felix
Freelance Network / Security Engineer
kfelix  ----a---t---socpuppets ---d---o---t---com

     ^      ^
=(  @   @ )=
          o
       /     \




Basic Public Facing DNS securing tips from socpuppets


Securing DNS bind named servers . Here’s a few tips on how to properly secured and lock down a DNS server.

DNS is a crucial element in any organization, And both interior and exterior name-servers, need proper care and design to prevent problems.

In this blog we will look at some of our options and means for securing a name server.

Here’s a typical named.conf format that I like to use


include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";
include "/etc/bind/named.conf.reverse";
include "/etc/bind/rndc.key";

acl dns-server {  192.168.122.78/32;
                  192.168.122.67/32;
                  127.0.0.1/32;
                 };
acl internal {

        127.0.0.1/32;
        10.2112.0/24;
        10.2113.0/24;
        192.168.122.0/24;
        192.25.218.0/24;
        192.25.219.0/24;
        192.25.222.0/24;
        192.25.223.0/24;

};

acl blacklist {



              0.0.0.0/8;
              10.0.0.0/8;
#            127.0.0.0/8;
              172.16.0.0/12;
              192.168.0.0/16;
              192.0.2.0/24;
              169.254.0.0/16;
              127.0.0.0/8;
              224.0.0.0/4;
              240.0.0.0/4;
              255.255.255.255/32;
};

#

acl transfer {
            12.23.34.35;
            196.1.5.1;
            192.168.122.67;
            69.16.11.18;
            192.5.3.9; 
            33.23.33.83;

};


controls {
         // inet 127.0.0.1  allow { localhost; 192.168.122.67; } keys { rndc-key
; };
        inet * port 953 allow { dns-server; } keys { rndc-key; };
};

server 19.1.3.49 {
        keys { rndc-key; };
};

looks intimidating ? Will not at all.

DNS needs securing  for numerous reasons & to avoid becoming a victim and/or being compromised or becoming  reflector in a DNS reflection attack.

****************************************************************************
One of the 1st security rule that should be followed  if  & you do nothing else; 

" close-off your dns server from being an open-resolver". 
****************************************************************************


What  this means, We only want resolution for prefixes ( ip address ) that are our clients. The rest of the world  can not use my server local and precious dns-server resources. If do little in deploying security practices around your dns-server, this is the one most important step.

Some DNS servers are open-resolvers ( GooglePublid DNS, DNScloud, OPpenDNS,etc...). But they are intended so , & by design and function.

You can follow  openresolver tracking at the follow website;

http://openresolverproject.org/

< make sure you don't become, yet another statistics >

I'm consulting with 3 ISP currently ( 1 outside of the USA and one in EMEA  region ) and on how to combat and close down open-resolvers. Here's a snapshot of just one of 64 class Cs from my USA ISP provider that I'm working with;



The above link is a good tool to generate quick information for tackling open-resolvers. Use it and audit your address space on some periodical schedule.


A quick means to control recursive routing  is; " via the ACLs concept" . In the above cfg we have have a few ACLs defined.

A: We blacklist martians or address that should never hit our dns server from the outside;


acl blacklist {

              0.0.0.0/8;
              10.0.0.0/8;
#              127.0.0.0/8;
              172.16.0.0/12;
              192.168.0.0/16;
              192.0.2.0/24;
              169.254.0.0/16;
              127.0.0.0/8;
              224.0.0.0/4;
              240.0.0.0/4;
              255.255.255.255/32;
};

Notice how  I have 127.0.0.0/8 allowed? I was testing locally on this particular dns and querying against localhost so I had to allow this action. All of these address are bogus if entering from the internet and your DNS-server would not be successful in delivering the response. So why waste time responding to these "martians"?

Keep in mind a lot of IT/networks leaks rfc1918 private or worst APIPA ranges etc....... So this is a ongoing problem,  and you should NOT  treat this as an attack or abuse of your name-server. Also don't get excited,  or waste your time diagnosing why a 169.254.22.33 is querying for a resource-record :)

Just filter it!


B: Next, we set the trusted space that we will allow recursive lookups from;

acl internal {

        127.0.0.1/32;
        10.2112.0/24;
        10.2113.0/24;
        38.2.22.22/32;
        192.168.122.0/24;
        192.25.218.0/24;
        192.25.219.0/24;
        192.25.222.0/24;
        192.25.223.0/24;

};

Acl entries are simple and straightforward, We list the series of ip_address and by using a CIRD prefix style & we can specify a whole range or a singlehost ip_address ( /32 )


Okay now that we have  these 2 defined,  we apply them to our dns-server;



NOTE:  This is ineffect a whitelist and blacklist,  of who we allow and who we don't answer queries for and for the allowance who we provide recursion for.

A address that matches the blacklist is drop and any client asking for recursive lookups who's not allowed would be dropped with a reject message similar to the below;


Notice how this comcast dns server does not answer recursive lookups, & sourced for my non-comcast address?




Now moving on, we should restrict zone transfer. And you guessed it, we could do this via firewall policies or within our named.conf ACLs or a combination of both. If you run into problem & with zone transfers; " make sure you check any layer3 routers/firewall  acl/policies and your named configuration files"

here's I'm only allow these slave dns-servers  to actually transfer zone  database information;

acl transfer {
            12.23.34.35;
            196.1.5.1;
            192.168.122.67;
             69.16.11.18;
            192.5.3.9; 
            33.23.33.83;

};

And we apply this in our named configuration file similar to the below;



Any hosts not listed would be denied , any  any execution of a  AXFR ( zone-transfers ) , would result in a refusal. And like the above example, a simple rejected, or refused  message similar to the below should be displayed;





Okay moving on.

Now to hide our named version, and limiting a potential attacker from  determining what your running. You  mask this very quickly  by either an ACL in some dns-instances or by placing some bogus information.


In my case I masked the version with some bogus wording called "BYE"



So from the outside, a potential hacker will not learn of your version. Here's a few example using the command dns-utilities of  host dig and nslookup , & on how one could determine the version and you will see examples of how I masked this off from  external probing sources.

And  one example of a dns-server for example.com,  that did not hide it's version details btw






and our public dns-server for example.com server , shows it's hand and provides  dns-server version details via nslookup



Okay that's the basic steps for DNS protection.  To recap;


1: do NOT  become a openresolver
2: lock down who can query against your dns-server
3: lock down  any   zone-transfer and from just ONLY your slaves dns-servers
4: mask you dns version details from any external probes

Other security measures that should be looked at,  but are  not 100% required, but is a good ideal;

1: rate-limit DNS traffic from your DNS-server to prevent becoming a flooder
2: stack your dns-server behind a load-balancer and impose limits or controls
3: deploy bind rate-limit options and set the number of queries per-second that your server attends per-source


here's some examples;


e.g ( bind rate-limit options


options {
    directory "/var/named/conf";    rate-limit { responses-per-second 10;
    };
};


e.g  ( cisco traffic policer rate-limiting traffic to  destination not trusted via a class-map and ACL )

!
!    define trust space 1st via a deny statement
ip access-list 101 deny udp any eq 53 host 1.1.1.1
ip access-list 101 deny udp any eq 53 192.0.0.0 0.255.255.255
!    apply any any for everybody else
ip access-list 101 permit udp any eq 53  any
!
class-map dns-traffic
 match access-group 101
!
!
policy-map dns-policer-at-socpuppets
 class dns-traffic
  police 768000 1000 1000 conform-action transmit exceed-action set-qos-transmit 1   violate-action drop



My general rule and just me personally, unless your a dns-hosting company  or a ISP, no more than 10% of  your outgoing traffic  should  not be DNS. If you have more than 10% of your outgoing traffic being DNS  response, you probably have something misconfigured or being a victim of a flooder  source or you have a OpenResolver on your LAN(s).

So on a 100mbps link, that;s 10mbps of dns-respsonses or on a 1gige that 100mbps of dns-responses.



Ken Felix
Freelance Network / Security Engineer
kfelix  ----a---t---socpuppets ---d---o---t---com

     ^      ^
=(  @   @ )=
          o
       /     \