Networking-Blog

My WordPress Blog

Stateful vs. Stateless Firewalls

A firewall can be described as being either Stateful, or Stateless.

STATELESS

Stateless firewalls watch network traffic, and restrict or block packets based on source
and destination addresses or other static values. They are not ‘aware’ of traffic patterns
or data flows.

A stateless firewall uses simple rule-sets that do not account for the possibility that a packet
might be received by the firewall ‘pretending’ to be something you asked for.

STATEFUL

Stateful firewalls can watch traffic streams from end to end. They are are aware of communication
paths and can implement various IP Security (IPsec) functions such as tunnels and encryption.
In technical terms, this means that stateful firewalls can tell what stage a TCP connection is in
(open, open sent, synchronized, synchronization acknowledge or established), it can tell if the
MTU has changed, whether packets have fragmented etc.

Neither is really superior and there are good arguments for both types of firewalls.
Stateless firewalls are typically faster and perform better under heavier traffic loads.
Stateful firewalls are better at identifying unauthorized and forged communications.

CBAC

When your router is running IOS image with FW feature, you can implement CBAC as a
Stateful Firewall IOS-based. With such inspection, the router can inspect inbound traffic from
outside such as The Internet to inside the network. The router can also inspect outbound traffic
from inside the network to outside.


Cisco 3G 887G Sim Profiles

These Profiles need to be entered in enable mode on router.
Use correct profile depending on Network Sims its on.

For o2 Sims :

Authentication: Normal
Network type: Ipv4
cellular 0 gsm profile create 1 mobile.o2.co.uk ipv4 chap web web

!

For Vodaphone Sims :

Authentication: Normal
Network type: Ipv4
cellular 0 gsm profile create 1 internet ipv4 chap web web

!

For Tmobile Sims :

Authentication: Normal
Network type: Ipv4
cellular 0 gsm profile create 1 general.t-mobile.uk ipv4 chap web web

!

For 3G Sims :

Authentication: Normal
Network type: Ipv4
cellular 0 gsm profile create 1 3internet

!

chat-script mobile “” “ATDT*98*1#” TIMEOUT 60 CONNECT

!

interface Cellular0
dialer string mobile
ppp chap hostname web
ppp chap password 0 web

!

line 3
exec-timeout 0 0
script dialer
mobile

Additional Info :

All settings are case sensitive !

Vodafone

APN (contract): internet
APN (PAYG): pp.vodafone.co.uk
Username: web
Password: web

Orange

APN: orangeinternet
Username: leave blank
Password: leave blank

O2

APN (contract): mobile.o2.co.uk
APN (PAYG): m-bb.o2.co.uk
Username: web
Password: web

T-Mobile

APN: general.t-mobile.uk
Username: leave blank
Password: leave blank

Three

APN: 3internet
Username: leave blank
Password: leave blank

Tesco Mobile (uses the O2 network)

APN: prepay.tesco-mobile.com
Username: tescowap
Password: password

Virgin Mobile (uses the T-Mobile network)

APN: goto.virginmobile.uk
Username: user
Password: leave blank

BT Mobile (uses the Vodafone network)

APN: btmobile2.bt.com
Username: bt
Password: bt

ASDA Mobile (uses the Vodafone network)

APN: asdamobiles.co.uk
Username: web
Password: web

Manx Telecom (Isle of Man)

APN: 3gpronto
Username: leave blank
Password: leave blank

Sure Mobile (Guernsey & Isle of Man)

APN: internet
Username: leave blank
Password: leave blank

Wave Telecom (Guernsey)

APN: pepper
Username: leave blank
Password: leave blank

Airtel Vodafone (Guernsey)

APN: airtel-ci-gprs.com
Username: leave blank
Password: leave blank

Sure Mobile (Jersey)

APN: internet

Username: leave blank
Password: leave blank
jersey Telecom (Jersey)

APN: pepper

Username: leave blank
Password: leave blank

Airtel Vodafone (Jersey)

APN: airtel-ci-gprs.com
Username: leave blank
Password: leave blank

CISCO 857 GET SNMP DSL STATS

Cisco 857 mib info needed :

attenuationoid=1.3.6.1.2.1.10.94.1.1.3.1.5.12
downsnroid=1.3.6.1.2.1.10.94.1.1.3.1.4.12
downloadrateoid=1.3.6.1.2.1.10.94.1.1.4.1.2.12
uploadrateoid=1.3.6.1.2.1.10.94.1.1.5.1.2.12

!
!

GET SNMP DSL STATS

getstats.sh

#!/bin/bash
#Ash Salman

#OIDS (From Cisco ADSL-MIB)
attenuationoid=1.3.6.1.2.1.10.94.1.1.3.1.5.12
downsnroid=1.3.6.1.2.1.10.94.1.1.3.1.4.12
downloadrateoid=1.3.6.1.2.1.10.94.1.1.4.1.2.12
uploadrateoid=1.3.6.1.2.1.10.94.1.1.5.1.2.12

#Community String
community=
rocaww

#Prepare CSV
if [ -a
results.csv ]
then
echo “File exists… Removing and preparing CSV headers”
rm results.csv
else echo “Preparing CSV headers”
fi
echo Name,Attenuation,Downstream_SNR,Downstream_Sync,Upload_Sync >
results.csv

#Get Statistics
echo “Reading sites from
name-ip-map.txt”
while read name ip; do
echo “Processing $name…”
attenuation=`snmpget -v2c -Oqv -c $community $ip $attenuationoid`
downsnr=`snmpget -v2c -Oqv -c $community $ip $downsnroid`
downrate=`snmpget -v2c -Oqv -c $community $ip $downloadrateoid`
uploadrate=`snmpget -v2c -Oqv -c $community $ip $uploadrateoid`
echo $name,$attenuation,$downsnr,$downrate,$uploadrate >>
results.csv
done < name-ip-map.txt

!
!

Name and Public ip addresses of remote sites to run script based on :

name-ip-map.txt

RATHBONE01 85.234.87.193
RATHBONE02 85.234.87.194
RATHBONE03 85.234.87.195
RATHBONE04 85.234.87.196
RATHBONE05 85.234.87.197
RATHBONE06 85.234.87.198
RATHBONE07 85.234.87.199
RATHBONE08 85.234.87.200
RATHBONE09 85.234.87.201
RATHBONE10 85.234.87.202

!
!

results.csv

Name,Attenuation,Downstream_SNR,Downstream_Sync,Upload_Sync
RATHBONE01,60,135,8128000,864000
RATHBONE02,200,145,8128000,832000
RATHBONE03,135,40,4512000,448000
RATHBONE04,185,140,6848000,800000
RATHBONE05,290,155,7040000,800000
RATHBONE06,320,180,6656000,832000
RATHBONE07,135,150,8128000,864000
RATHBONE08,140,150,8128000,832000
RATHBONE09,325,85,8064000,864000
RATHBONE10,390,80,6432000,800000

!
!

copy & paste the results from the results.csv file into an excel spreadsheet.

CISCO Policy based Routing (PBR) : route-map & co.

Route-map can be used in a lot of application, in most of them, the aim is enabling the network engineer
to override the route table and influence which way traffic flows.

Below you will find a configuration sample of Policy Based Routing (PBR) we use to route different
subnet through different equipments.

!

!
!
!
!
!
!
!
!
!

We’ll route :

– Packets from 10.20.10.0/24 (vlan 10) to 172.20.10.0/24 thru Link 2
– Packets from 10.20.20.0/24 (vlan 20) to 172.20.10.0/24 thru Link 1
– Other Packets thru gateway 10.20.5.254 on Gigabit Ethernet interface 3/48

Policy based routing in Cisco Routers can be performed by using “route-map” and then applying as a
policy to the interface of the IP Packets.

The route-map has a list of “match” and “set” commands where match defines the criteria under which the
policy routing is performed (standard or Extended ACL) and set defines the actions to perform when match
criteris met (i.e., set next hop)
.

I change the routing to a particular network only from a particular subnet which is defined
in a standard ACL. This ACL is then matched in a route-map and applied as an IP policy for
routing change for the change in routing behaviour.

First Step create ACLs :

BraveHeart-R-C#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
BraveHeart-R-C(config)# access-list 100 permit ip 10.20.10.0 0.255.255.255 172.20.10.0 0.255.255.255
BraveHeart-R-C(config)# access-list 101 permit ip 10.20.20.0 0.255.255.255 172.20.10.0 0.255.255.255
BraveHeart-R-C(config)# access-list 102 permit ip 10.20.10.0 0.255.255.255 any
BraveHeart-R-C(config)# access-list 102 permit ip 10.20.20.0 0.255.255.255 any

The access list id doesn’t matter for the matching order.

Second Step create route-map :

We will create a route map named Global-route map.
The matching order is the id number of the route map 9->10->11

BraveHeart-R-C#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
BraveHeart-R-C(config)# route-map Sample-routemap permit 9
BraveHeart-R-C(config-route-map)# match ip address 101
BraveHeart-R-C(config-route-map)# set ip next-hop 10.20.6.1
BraveHeart-R-C(config)# route-map Sample-routemap permit 10
BraveHeart-R-C(config-route-map)#  match ip address 100
BraveHeart-R-C(config-route-map)#  set ip next-hop 10.20.7.1
BraveHeart-R-C(config)# route-map Sample-routemap permit 11
BraveHeart-R-C(config-route-map)#  match ip address 102
BraveHeart-R-C(config-route-map)# set default interface GigabitEthernet 3/48

That creates a route-map called “Sample-routemap” and matches the ACLs 100,101,102 where the
source network for which the route-map should be actioned.

Apply Policy Route-map to interface

This route-map is now applied to the interface vlan 10 and 20.

BraveHeart-R-C#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
BraveHeart-R-C(config)#int vlan 10
BraveHeart-R-C(config-if)# ip policy route-map Sample-routemap
BraveHeart-R-C(config-if)#exit
!
BraveHeart-R-C(config)#int vlan 20
BraveHeart-R-C(config-if)# ip policy route-map Sample-routemap
BraveHeart-R-C(config-if)#end

Now all rules configured should work (use traceroute to check the link you use ;-)

Policy Based Routing

Step 1 – define an ACL

Keep in mind that whatever is permitted by this ACL is what will be matched.
You don’t want to permit everything. Usually, I take advantage of the implicit deny at the bottom of the ACL
and just create an ACL that permits what I am going to take action on in the route-map.

So, just create a simple ACL:

Router(config)# ip access-list extended FROM_PRIVATE
Router(config-ext-nacl)# permit ip 192.168.0.0 0.0.255.255 192.168.0.0 0.0.255.255

Step 2 – create a route-map

To create a route-map, go into route-map configuration mode, like this:

Router(config)# route-map reroute permit 10

Next, set your match policy to match the traffic in ACL REMOTEVPN, like this :
This will match all the traffic permitted through ACL REMOTEVPN.

Router(config-route-map)# match ip address FROM_PRIVATE

Next, you need to set some action on that traffic. What do you want to happen to that traffic?
Let’s tell the router to send it out interface Fast Ethernet 3/0, like this:

Router(config-route-map)# set interface FastEthernet0/0

!

This will match any IP from the major private networks, and will process them like normal
(The route map will not process
20 if it matches 10). The next map changes the next hop to 192.168.1.6
if it didn’t match the private IPs; in other words, if it’s a publicip, send it to 192.168.1.6

Router(config)# route-map reroute permit 20
description INTERNET_BOUND_TRAFFIC_TO_ISA_SERVER
set ip next-hop
192.168.1.6

Step 3 – Apply the route-map to the interface

Next, you need to apply this policy/route-map to the interface where the traffic is coming in.

Router(config)# interface Fast Ethernet 3/0
Router(config-if)# ip policy route-map reroute


According to the official Cisco Policy Routing documentation,
“One interface can have a only one route map policy applied“.tag; but you can have
several route map entries, each with its own sequence number.

Entries are evaluated in order of their sequence numbers until the first match occurs. If no match occurs,
packets are routed as usual
.”

Now exit and you are done!
You can view your route-maps with show route-map.

Config in Place :

Router(config)# ip access-list extended FROM_PRIVATE
Router(config-ext-nacl)# permit ip 192.168.0.0 0.0.255.255 192.168.0.0 0.0.255.255
!
Router(config)# route-map reroute_remotevpn permit 10
Router(config-route-map)# match ip address FROM_PRIVATE
Router(config-route-map)# set interface fastethernet0/0
!
!

Router(config)# route-map reroute permit 20
Router(config-route-map)# description INTERNET_BOUND_TRAFFIC_TO_ISA_SERVER
Router(config-route-map)# set ip next-hop
192.168.1.6

!
Router(config)# interface Fa0/1
Router(config-if)#
ip policy route-map reroute

Static Routes in place :

ip route 0.0.0.0 0.0.0.0 192.168.1.6
ip route 80.74.16.8 255.255.255.248 81.134.196.177
ip route 80.74.16.240 255.255.255.255 81.134.196.177
ip route 80.74.17.9 255.255.255.255 81.134.196.177

***************************************************************************************

Because it’s using route maps, and ACLs, you can create some complex rules, for example :

ip access-list extended FROM-PRIVATE
permit ip 10.0.0.0 0.255.255.255  any
permit ip 172.16.0.0 0.0.15.255  any
permit ip 192.168.0.0 0.0.255.255  any

!
route-map Modify-Default permit 5
description “Match Private IPs“
match ip address FROM-PRIVATE

!
route-map Modify-Default permit 10
description “Match all public IPs“
set ip next-hop 100.100.100.1


This will match any IP from the three major private networks, and will process them like normal
(
The route map will not process 10 if it matches 5).  The next map changes the next hop to 100.100.100.1
if it didn’t match the private IPs; in other words, if it’s a publicip, send it to 100.100.100.1.

***************************************************************************************

Cisco IPSec, NAT, Port Forwarding Issue

I have an issue on a Cisco router using IOS 12.4(20)T3 where I already have one port forward that
works which uses a route-map to avoid dramas with the remote subnet begin subjected to the
static port forward locally
.

Traffic destined for the VPN tunnel cannot be natted. It needs to travel through the vpn tunnel
untranslated. A special nat configuration must be used to prevent vpn “interesting” traffic from being
translated while still translating normal internet bound traffic.

!

This is the working configuration :

ip nat inside source static tcp 192.168.100.2 80 210.xxxx 80 route-map No-Eden-NAT extendable
ip nat inside source static tcp 192.168.100.2 443 210.xxxx 443 route-map No-Eden-NAT extendable
ip nat inside source static tcp 192.168.100.2 3389 210.xxxx 3389 route-map No-Eden-NAT extendable

And below is listed the route-maps :

route-map No-Eden-NAT permit 10
match ip address 120

!

access-list 120 remark “Deny Eden subnet being routed in via port forward”
access-list 120 deny   ip host 192.168.100.2 192.168.101.0 0.0.0.255

##############################################

Here is the short list of commands :

ip access-list extended NAT
deny ip 192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255
permit ip 192.168.1.0 0.0.0.255 any
!
route-map POLICY-NAT 10
match ip address NAT
!
ip nat source route-map POLICY-NAT interface s0/0 overload
ip nat inside source static tcp 192.168.1.10 25 12.34.56.2 25 route-map POLICY-NAT extendable

##############################################

Same route-map POLICY-NAT can be used to accomplish the same task.
This will deny local lan traffic from being NaTTed across IPSEC VPN and cross the
VPN Tunnel untranslated and at the same time allow local break-out to the internet.

Cisco multiple Vlan Trunking

Trunking

  • VLANs are local to each switch’s database, and VLAN information is not passed between switches.
  • Trunk links provide VLAN identification for frames traveling between switches.
  • Cisco switches have two Ethernet trunking mechanisms: ISL and IEEE 802.1Q.
  • Certain types of switches can negotiate trunk links.
  • Trunks carry traffic from all VLANs to and from the switch by default but can be configured to carry
    only specified VLAN traffic.
  • Trunk links must be configured to allow trunking on each end of the link.

    To enable trunking between the switches & specify a range of ports use the following steps :

    switchport trunk allowed vlan 1-5
    switchport mode trunk
    switchport nonegotiate
    speed 100
    duplex full

    Now Create the Vlan’s on the Switch :

    vlan database
    vlan 2 name MEDIA
    vlan 3 name DMZ
    vlan 4 name OFFICE
    vlan 5 name ACCOUNTS

    Now exit : This will create a vlan.dat file in flash memory.
    Don’t forget the ” ip default-gateway 192.168.1.1″ command :
    where 192.168.1.1 is the Layer3 Trunking Device.

    Now let create Layer 3 interVLAN Routing :

    Whenever hosts in one VLAN need to communicate with hosts in another VLAN, the traffic
    must be routed between them. This is known as
    inter-VLAN routing. On Catalyst switches it is
    accomplished by creating
    Layer 3 interfaces (Switch virtual interfaces (SVI) ).

    Verify ip routing is enabled,  Enable routing on the switch by using the ip routing command.

    interface FastEthernet0/1
    description TRUNK_PORT
    no ip address
    speed 100
    full-duplex
    !
    interface FastEthernet0/1.1
    description TRUNK_VLAN 1
    encapsulation dot1Q 1 native
    ip address 192.168.1.1 255.255.255.248
    !
    interface FastEthernet0/1.2
    description MEDIA
    encapsulation dot1Q 2
    ip address 192.168.2.1 255.255.255.248
    !
    interface FastEthernet0/1.3
    description DMZ
    encapsulation dot1Q 3
    ip address 192.168.3.1 255.255.255.248
    !
    interface FastEthernet0/1.4
    description OFFICE
    encapsulation dot1Q 4
    ip address 192.168.4.1 255.255.255.240
    !
    interface FastEthernet0/1.5
    description ACCOUNTS
    encapsulation dot1Q 5
    ip address 192.168.5.1 255.255.255.248

    Lastly :

    Configure the default route for the Layer 3 switch.
    (config)#ip route 0.0.0.0 0.0.0.0 200.1.1.2

    Note : On layer 2 devices, only 1 vlan can exist with an ip address assigned,
    This ip address is only for managment purpose to device.
    Only 1 vlan will be active status : up up.
    Verify Vlan’s on Layer2 Switch are created “show vlans“, in order to have vlan
    info pass over the trunk to a layer 3 device.

Cisco Storm Control

I remember when I first saw Storm Control in a config and thought “woah, whats that looks
really confusing”, but really its pretty simple stuff.

We use storm control to rate limit layer 2 traffic, this helps us prevent a subnet from being
flooded with broadcasts, multicasts which would adversely affect the performance of the entire subnet.

Storm Control can only be configured on physical interfaces and will not work on subinterfaces,
or an LACP/PAGP interface.

Configuration

The first command shown limits the broadcast to 200pps, and if this limit is reached will not forward
any more broadcasts until this is reduced to 150pps.

(config-if)#storm-control broadcast level pps 200 150

Multicast and unicast traffic can also be limited, the maximum level can also be entered as a percentage
instead of pps, in the example below multicasts can use up to 5% of the interface bandwidth,
and once that limit is reach no more multicasts will be forwarded until it drops to 4.5% of the total
interface bandwidth

(config-if)#storm-control multicast level 5 4.5

In the final example unicast is limited to 80% of the interface bandwidth but a second value is not
specified, this causes all unicast to be forwarded up to 80% of the bandwidth and it does not force the
traffic to wait until it drops below a second level.

(config-if)#storm-control unicast level 80

The default response for storm control is the drop packets which are over the rate limit, and create a
syslog message, we can also generate a SNMP trap with the command

(config-if)#storm-control action trap

The show commands for this are also really easy :
(config-if)#show storm-control port [unicast|broadcast|multicast]

Configuration Sample :

Understanding Storm Control


Storm control prevents traffic on a LAN from being disrupted by a broadcast,
multicast, or unicast storm on one of the physical interfaces.

A value of 0.0 means that all broadcast, multicast, or unicast traffic on that
port is blocked.

config t
int fa0/1
storm-control broadcast level 80.00 50.00
storm-control multicast level 80.00 50.00
storm-control unicast level 80.00 50.00
storm-control action shutdown
storm-control action trap

Switch(config-if)# storm-control broadcast level 0
Switch(config-if)# storm-control unicast level 0
Switch(config-if)# storm-control multicast level 0

My understanding of “switchport block multicast” is that it blocks flooding of multicast traffic to ports
that are unknown or unjoined for a particular multicast group.

This seems to be a layer 2 multicast control?
“Note Only pure Layer 2 multicast traffic is blocked. Multicast packets that contain IPv4 or IPv6
information in the header are not blocked
.”

So same concept, but different layers!  The “switchport block” whether unicast or multicast is designed
to affect the Layer2 flooding concepts for unknown unicasts or multicast frames.

High CPU Utilization in Exec and Virtual Exec Processes

router#show process | i CPU|Exec
CPU utilization for five seconds: 0%/0%; one minute: 0%; five minutes: 0%
The amount of data transferred through each vty session can be verified with
the show tcp command:
router#show tcp vty 0

Preventing Processes from Hanging
Process Watchdog 


What the Process Watchdog does is monitors the router’s processes and if
one is determined to have hung, it carries out a pre-determined action.

There are several modes that the Process Watchdog can be set to.
These different modes are: normal, hang, reload, terminate. 

Now that you know the various modes, you can pick a mode and then
type this command to initiate the Process Watchdog.
To run the command type:


To prevent a process from wedging on the CPU, we use the following
command: 
scheduler process-watchdog.

There are four options to this command:

1. scheduler process-watchdog hang
This will keep the process in the process table, but will no longer schedule it on the CPU.
2. scheduler process-watchdog normal
This is the "default" behaviour as decided by the developers. The result is difficult to predict unless you have access to the source code.
3. scheduler process-watchdog reload
This will reload the router. While this may seem a bit harsh, keep in mind that the loss of certain processes (e.g. IP Input) will all most certainly leave the router in an unusable state. In this case it would be better to reload.
4. scheduler process-watchdog terminate
This choice will result in the termination of the process and the continued operation of the router. However, as noted above, the loss of some key process is certain to have an adverse affect on the router.
Allowing the scheduling of lower priority processes ! In cases where extremely high network load presents itself on the inter- face of a router, it is possible that other tasks will not be able to run. By default, the Cisco IOS allocates 5% of the CPU time to the lower priority tasks.During a high load event, such as a DDOS, this default may be insufficient to ensure that other tasks acquire CPU time, such as routing protocol updates and CEF table maintenance. To modify the default behaviour, we utilize the scheduler allocate command. This is a global command, and is used thusly: scheduler allocate 4000 200 Where 4000 is the maximum number of microseconds to allocate to fast switching any single network interrupt context. ! Where 200 is the minimum guaranteed number of microseconds to allocate to process level tasks while network interrupts are masked. The defaults are 4000 and 200, as shown above. Modifying the interval at which statistics are gathered ! By default, the Cisco IOS gathers statistics for the various counters at an interval of 300 seconds, or five minutes. While this is suitable for most states of operation, there may be select periods where a more granular (or gross) interval is required. Keep in mind that this does have an effect on the performance of the router, however.To change the statistics gathering interval, we use the global load-interval command thusly: load-interval 300 Where 300 is the number of seconds we wish to use as our interval. If you set this to some more granular figure (e.g. 30 seconds), remember to set it back when you have completed your data gathering.
! ! Memory Leak Bug
A memory leak occurs when a process requests or allocates memory and then forgets to free (de-allocate) the memory when it is finished with that task. As a result, the memory block is reserved until the router is reloaded. Over time, more and more memory blocks are allocated by that process until there is no free memory available. Depending on the severity of the low memory situation at this point, the only option you may have is to reload the router to get it operational again.
!

(in enable mode) from your Cisco device, you can use Output to display
potential issues and fixes :
show memory allocating-process totals | show memory summary | show technical-support
 
The *Dead* Process
The *dead* process is not a real process. It's there to account for the 
memory allocated under the context of another process which has terminated. 
The memory allocated to this process is reclaimed by the kernel and returned 
to the memory pool by the router itself when required. 
This is the way IOS handles memory.
Router#show memory dead