Klips Manual Key Protected Connection Examples


Macros

These definitions of macros make the commands more readable and the scripts easier to use by centralising the information. Obviously, the keys are for example purposes only and cryptographically strong keys should be substituted.
		hmask=255.255.255.255
		nmask0=0.0.0.0
		nmask16=255.255.0.0
		nmask24=255.255.255.0
		nmask28=255.255.255.240
		nmask29=255.255.255.248

		local_sg=207.236.55.216
		local_nexthop=207.236.55.1
		local_sg_bcast=207.236.55.255
		local_sg_nmask=$nmask24
		local_net=192.168.2.0
		local_nmask=$nmask24

		remote_sg=209.157.90.146
		remote_net=209.157.90.160
		remote_nmask=$nmask29

		ext_sg=209.157.90.198
		ext_net=209.157.90.192
		ext_bcast=209.157.90.199
		ext_nmask=$nmask29

		default_net=0.0.0.0
		default_bcast=255.255.255.255
		default_nmask=$nmask0

		ipsecdev=ipsec1
		aliasdev=eth0:1
		physdev=eth2

		iv=0x0123456789abcdef
		enckey8=0x0123456789abcdef
		enckey24=0x0123456789abcdef0123456789abcdef0123456789abcdef
		authkey16=0x0123456789abcdef0123456789abcdef
		authkey20=0x0123456789abcdef0123456789abcdef01234567
    

Setup

These commands must be run before any of the connection-specific commands will work.
		depmod -a	# only if klips is compiled as a module
		modprobe ipsec	# only if klips is compiled as a module
		tncfg --attach --virtual $ipsecdev --physical $physdev
		ifconfig $ipsecdev $local_sg broadcast $local_sg_bcast netmask $local_sg_nmask
    

Unload

These commands must be run before the module can be unloaded.
		tncfg --detach --virtual $ipsecdev
		ifconfig $ipsecdev down
		rmmod ipsec	# only if klips is compiled as a module
    
Warning: Each of the Setup scripts first deletes the route for the destinations it needs to protect, if it exists. When the route gets deleted with the deletion of the protected connection, that route will no longer exist. This route must be put back manually, or reboot the network configuration if it was installed automatically.

Transport mode

Transport mode is used between two hosts that each have IPSEC capabilities. They don't rely on a security gateway since they are by definition same. This mode has a lower overhead per packet and is therefore more efficient. The outside header is protected against modification if authentication is used.

Assumptions: Both machines have had networking set up and can pass packets.


Tunnel mode

Tunnel mode is used between two security gateways to protect their own traffic to another security gateway, or any combination of hosts behind it who may or may not be IPSEC aware. Only the inner headers are protected if authentication is enabled. There is extra overhead since there is an internal IP header. This mode is often preferable to make traffic analysis more difficult.

Assumptions: Any subnets have been set up and all machines can see the internet.

Transform Examples

A number of different transforms can be used to provide the protection intended by the IPSEC protocol suite. All these examples are using transport mode, but the techniques are equally applicable to tunnel mode, adding the extra SA to the spigrp command as necessary.

Assumptions: Both machines have had networking set up and can pass packets.