VPNs
IPSec
| Protocol | Notes |
|---|---|
| Authentication Header (AH) | RFC2402. Authenticate and secure data. Data origin auth, optional anti-replay. No encyrption (confidentiality) |
| Encapsulating Security Payload (ESP) | Authenticate secure and encrypt data. Header/trailer "encapsulates". Origin auth, anti-replay, data confidentiality. |
| Internet Key Exchange (IKE) | Negotiates security parameters and authentication keys |
Both AH and ESP can operate in Tunnel Mode or Transport Mode
Tunnel Mode : Encapsulates the entire IP packet. The encapsulating IP header will have tunnel endpoint IPs as src/dst.
Transport Mode: Encapsulates payload only. IPSec header inserted after Ip header. Original src/dst IPs are used for routing. Only transport layer and above are protected.
5 Main steps to build IPSec VPN:
- Process initialization - Identify interesting traffic (crypto acl).
- IKE Phase 1 - SA (security association) is negotiated
- IKE Phase 1.5 - Optional Xauth
- IKE Phase 2 - IPSec SA is negotiated
- Data transfer
- Tunnel termination (idle or after configurabe number of bytes [or lifetime])
IKE Protocols
ISAKMP - Internet Security Association and Key Management Protocol. Handles all parameter negotiation for SA's.
Oakley - Uses Diffie-Hellman algorihtm for key excahnges. DH is a protocol that permits two endpoints to exchange a shared secret key over an insecure channel.
IKE Modes
Main Mode - Quick mode always follows main mode. Six messages broken into 3 pairs (IPSec params/security policy), (Diffie-Hellman public key exchange), (ISAKMP session authentication)
Aggressive Mode - Abbreviated version of main mode. Quick mode always follows main mode. Six messages are condensed into 3 messages,
Quick Mode - Used in IKE phase 2. Negotiation of quick mode is protected by SA negotatiated in IKE phase 1.
Main difference between main and aggressive modes are the number of messages exchanged (6 vs 3). Policy negotation, Diffie-Hellman exchange, Peer authentication.
Other IKE functions: Dead peer detection (DPD ie. keepalives), NAT traversal (ie. UDP header inserted before ESP header), Mode configuration, Xauth
IKE Phase 1
- Mandatory
- Recipient will attempt to find a match for policies sent among its own policies starting with lowest numbered policy.
- Life time is the only parameter that does not have to match in the policies. Will use the lowest between both peers.
Config example
! Should be on by default
crypto isakmp enable
! IKE Phase 1. Lower number policy is higher priority when sent matching policies. Cannot be set to 0.
crypto isakmp policy 100
authentication pre-share
encryption 3des
hash md5
lifetime 86400
!
crypto isakmp key 6 CCNP address 172.12.123.3
!
crypto ipsec transform-set CCNP_LAB ah-md5-hmac
mode tunnel
!
crypto ipsec security-association lifetime seconds 1800
!
access-list 103 permit ip host 172.12.123.1 host 127.12.123.3
!
crypto map CCNP 100 ipsec-isakmp
match address 103
set peer 172.12.123.3
set transform-set CCNP_LAB
!
int Serial0
crypto map CCNP
Verification
sh crypto isakmp sash crypto isakmp policydebug crypto ipsecshow crypto ipsec sa
Misc
- ACLs need IP protocol 50 (ESP) and 51 (AH) open as well as UDP port 500 (IKE)
- Encryption key is called "public key" and decryption key is called "private key" in asymmetric encryption
- Each IPSec SA is one-way, so there are effectively two SA's (incoming, outgoing) tracked and maintenaned separately.
- IPSec SA is referenced in each IPSec packet by an SPI (security parameter index). Eliminates the need to send parameters in each packet.
GRE
- GRE header is 4 bytes and adds an additional IP header (20 bytes). Additional options can add up to 12 bytes of GRE header overhead.
- GRE is IP protocol 47 (in the outer IP header)

- Allows multicast traffic to pass through tunnel (where IPSec cannot do this natively)
Example config
int Loopback0
ip address 1.1.1.1 255.255.255.252
!
int Tunnel0
ip address 172.16.0.1 255.255.255.0
tunnel source Loopback0
tunnel destination 2.2.2.2
tunnel mode gre ip
!
- Tunnel destination is the IP address of the remote router
- Tunnel source is interface or IP address local to the router (best practice to use a loopback)
- Tunnel mode is gre ip by default (added in example above for clarity)
DMVPN
- Design concept (not a protocol)
- Spoke routers in hub-and-spoke topology can dynamically create VPN to another spoke. Does not require manual static tunnel configurations.
- Uses multipoint-GRE tunnels. Treated as NBMA (non-broadcast multi-access). One interface, multiple tunnels.
- NHRP (next-hop resolution protocol) facilitates dynamic tunnel establishment. Provides tunnel to physical interface address resolution. RFC 2332.
- NHRP clients (spokes) issue requests to the next hop server (hub) to obtain the physical address of another spoke router. NHRP clients (spokes), send a tunnel IP and physical IP to server (hub). Other clients ask the NHS (hub) for the physical address when building a tunnel
- IPSec cannot encrypt or tunnel multicast packets, which is why you might build GRE over IPSec tunnels for things like OSPF/multicast traffic.
Example configs
Hub config:
interface FastEthernet0/0
ip address 172.16.15.2 255.255.255.252
!
interface Tunnel0
ip address 192.168.0.1 255.255.255.0
ip nhrp map multicast dynamic
ip nhrp network-id 1
tunnel source 172.16.15.2
tunnel mode gre multipoint
ip nhrp network-id 1 uniquely identifies the DMVPN network; tunnels will not form between routers with differing network IDs. ip nhrp multicast dynamic enables forwarding of multicast traffic across the tunnel to dynamic spokes (required by most routing protocols)
Spoke config:
interface FastEthernet0/0
ip address 172.16.25.2 255.255.255.252
!
interface Tunnel0
ip address 192.168.0.2 255.255.255.0
ip nhrp map 192.168.0.1 172.16.15.2
ip nhrp map multicast 172.16.15.2
ip nhrp network-id 1
ip nhrp nhs 192.168.0.1
tunnel source 172.16.25.2
tunnel mode gre multipoint
show dmvpn
show ip nhrp
- Note: IP protocol 47 needs to be open in ACLs for GRE
Adding crypto:
crypto isakmp policy 10
authentication pre-share
crypto isakmp key P4ssw0rd address 172.16.0.0 255.255.0.0
!
crypto ipsec transform-set MyTransformSet esp-aes esp-sha-hmac
!
crypto ipsec profile MyProfile
set transform-set MyTransformSet
!
interface Tunnel0
tunnel protection ipsec profile MyProfile
Cisco EasyVPN
- After IKE proposals sent and accepted, Server authenticates the client via XAUTH (IKE extended authentication). Client response checked against RADIUS or TACACS+.
- Client requests additional info (IP, DNS, etc.), then IPSec SA estabished.
- Done
VRF-Lite
Basic example:
ip vrf VRF2
ip vrf VRF3
int fa0/0.2
ip vrf forwarding VRF2
int fa0/0.3
ip vrf forwarding VRF3
Note: apply IP to interface after vrf applied to interface
Ping: ping vrf VRF2 10.2.2.2
OSPF over VRF
router ospf 2 vrf VRF2
network 10.2.2.0 0.0.0.255 area 0
Show routing table: show ip route vrf VRF2
show vrf list
EVN (Easy Virtual Networking)
-
Instead of building sub0interaces, there is a VNET (virtual network trunk) carrying traffic tagged with a VNET tag.
-
VRF-lite over VLAN point-to-point subinterfaces
- Not proprietary
- Limited to 32 VRFs
- Has a "route replication" feature that grants each virtua network access to the RIB for every VRF.
ISP1(config)#vrf definition Blue
ISP1(config-vrf)#vnet tag 10
ISP1(config-vrf)#address-family ipv4
ISP1(config)#vrf definition Red
ISP1(config-vrf)#vnet tag 20
ISP1(config-vrf)#address-family ipv4
ISP1(config)#interface GigabitEthernet 1
ISP1(config-if)#vrf forwarding Blue
ISP1(config-if)#ip address 192.168.1.254 255.255.255.0
ISP1(config)#interface GigabitEthernet 2
ISP1(config-if)#vrf forwarding Red
ISP1(config-if)#ip address 192.168.2.254 255.255.255.0
ISP1(config)#interface GigabitEthernet3
ISP1(config-if)#vnet trunk
ISP1(config-if)#ip address 192.168.56.5 255.255.255.0
ISP1#show derived-config | begin GigabitEthernet3
interface GigabitEthernet3
vnet trunk
ip address 192.168.56.5 255.255.255.0
negotiation auto
!
interface GigabitEthernet3.10
description Subinterface for VNET Blue
encapsulation dot1Q 10
vrf forwarding Blue
ip address 192.168.56.5 255.255.255.0
!
interface GigabitEthernet3.20
description Subinterface for VNET Red
encapsulation dot1Q 20
vrf forwarding Red
ip address 192.168.56.5 255.255.255.0