Index:
IPXrouted(8)MAKEDEV(8)
ac(8)
accton(8)
acpiconf(8)
acpidb(8)
acpidump(8)
adding_user(8)
adduser(8)
adjkerntz(8)
amd(8)
amq(8)
ancontrol(8)
apm(8)
apmconf(8)
apmd(8)
arlcontrol(8)
arp(8)
asf(8)
atacontrol(8)
atm(8)
atmarpd(8)
atmconfig(8)
atrun(8)
authpf(8)
badsect(8)
bcmfw(8)
boot(8)
boot0cfg(8)
boot_i386(8)
bootparamd(8)
bootpd(8)
bootpef(8)
bootpgw(8)
bootptest(8)
bsdlabel(8)
bt3cfw(8)
btxld(8)
burncd(8)
camcontrol(8)
catman.local(8)
ccdconfig(8)
chat(8)
chkgrp(8)
chkprintcap(8)
chown(8)
chroot(8)
clri(8)
comcontrol(8)
comsat(8)
config(8)
conscontrol(8)
crash(8)
cron(8)
cvsbug(8)
daemon(8)
dconschat(8)
devd(8)
devfs(8)
devinfo(8)
dhclient-script(8)
dhclient(8)
digictl(8)
diskinfo(8)
disklabel(8)
diskless(8)
dmesg(8)
dnssec-keygen(8)
dnssec-signzone(8)
dump(8)
dumpfs(8)
dumpon(8)
editmap(8)
edquota(8)
extattrctl(8)
faithd(8)
fastboot(8)
fasthalt(8)
fdcontrol(8)
fdisk(8)
ffsinfo(8)
fingerd(8)
fixmount(8)
flowctl(8)
fore_dnld(8)
fsck(8)
fsck_4.2bsd(8)
fsck_ffs(8)
fsck_msdosfs(8)
fsck_ufs(8)
fsdb(8)
fsinfo(8)
fsirand(8)
ftp-proxy(8)
ftpd(8)
fwcontrol(8)
gbde(8)
gconcat(8)
geom(8)
getextattr(8)
getfmac(8)
getpmac(8)
getty(8)
ggatec(8)
ggated(8)
ggatel(8)
glabel(8)
gmirror(8)
gnop(8)
gpt(8)
graid3(8)
growfs(8)
gshsec(8)
gstat(8)
gstripe(8)
halt(8)
hccontrol(8)
hcsecd(8)
hcseriald(8)
hlfsd(8)
hprop(8)
hpropd(8)
iasl(8)
ifconfig(8)
ifmcstat(8)
ilmid(8)
inetd(8)
init(8)
intro(8)
iostat(8)
ip6addrctl(8)
ip6fw(8)
ipf(8)
ipfs(8)
ipfstat(8)
ipfw(8)
ipmon(8)
isdnd(8)
isdndebug(8)
isdndecode(8)
isdnmonitor(8)
isdnphone(8)
isdntel(8)
isdntelctl(8)
isdntrace(8)
ispcvt(8)
jail(8)
jexec(8)
jls(8)
kadmin(8)
kadmind(8)
kdc(8)
kerberos(8)
keyserv(8)
kgmon(8)
kgzip(8)
kldconfig(8)
kldload(8)
kldstat(8)
kldunload(8)
kldxref(8)
kpasswdd(8)
kstash(8)
ktrdump(8)
ktutil(8)
l2control(8)
l2ping(8)
lastlogin(8)
ldconfig(8)
loader.4th(8)
loader(8)
locate.updatedb(8)
lockd(8)
lpc(8)
lpd(8)
lptcontrol(8)
lsextattr(8)
lwresd(8)
mail.local(8)
mailstats(8)
mailwrapper(8)
makekey(8)
makemap(8)
makewhatis.local(8)
manctl(8)
map-mbone(8)
mdconfig(8)
mdmfs(8)
memcontrol(8)
mergemaster(8)
mixer(8)
mk-amd-map(8)
mknetid(8)
mknod(8)
mksnap_ffs(8)
mkuzip(8)
mld6query(8)
mlxcontrol(8)
mount(8)
mount_cd9660(8)
mount_devfs(8)
mount_ext2fs(8)
mount_fdescfs(8)
mount_linprocfs(8)
mount_mfs(8)
mount_msdosfs(8)
mount_nfs(8)
mount_nfs4(8)
mount_ntfs(8)
mount_nullfs(8)
mount_nwfs(8)
mount_portalfs(8)
mount_procfs(8)
mount_smbfs(8)
mount_std(8)
mount_udf(8)
mount_umapfs(8)
mount_unionfs(8)
mountd(8)
moused(8)
mrinfo(8)
mrouted(8)
mtest(8)
mtrace(8)
mtree(8)
named-checkconf(8)
named-checkzone(8)
named(8)
named.reconfig(8)
named.reload(8)
natd(8)
ndiscvt(8)
ndp(8)
newfs(8)
newfs_msdos(8)
newkey(8)
newsyslog(8)
nextboot(8)
nfsd(8)
nfsiod(8)
ngctl(8)
nghook(8)
nis(8)
nologin(8)
nos-tun(8)
nsupdate(8)
ntpd(8)
ntpdate(8)
ntpdc(8)
ntpq(8)
ntptime(8)
ntptrace(8)
pac(8)
pam_chroot(8)
pam_deny(8)
pam_echo(8)
pam_exec(8)
pam_ftpusers(8)
pam_group(8)
pam_guest(8)
pam_krb5(8)
pam_ksu(8)
pam_lastlog(8)
pam_login_access(8)
pam_nologin(8)
pam_opie(8)
pam_opieaccess(8)
pam_passwdqc(8)
pam_permit(8)
pam_radius(8)
pam_rhosts(8)
pam_rootok(8)
pam_securetty(8)
pam_self(8)
pam_ssh(8)
pam_tacplus(8)
pam_unix(8)
pccardc(8)
pccardd(8)
pciconf(8)
periodic(8)
pfctl(8)
pflogd(8)
picobsd(8)
ping(8)
ping6(8)
pnpinfo(8)
ppp(8)
pppctl(8)
pppd(8)
pppoed(8)
pppstats(8)
praliases(8)
procctl(8)
pstat(8)
pw(8)
pwd_mkdb(8)
pxeboot(8)
quot(8)
quotacheck(8)
quotaoff(8)
quotaon(8)
rarpd(8)
raycontrol(8)
rbootd(8)
rc(8)
rc.atm(8)
rc.d(8)
rc.early(8)
rc.firewall(8)
rc.local(8)
rc.network(8)
rc.pccard(8)
rc.sendmail(8)
rc.serial(8)
rc.shutdown(8)
rc.subr(8)
rcorder(8)
rdump(8)
reboot(8)
renice(8)
repquota(8)
rescue(8)
restore(8)
revnetgroup(8)
rexecd(8)
rfcomm_pppd(8)
rip6query(8)
rlogind(8)
rmail(8)
rmextattr(8)
rmt(8)
rmuser(8)
rndc-confgen(8)
rndc(8)
route(8)
route6d(8)
routed(8)
rpc.lockd(8)
rpc.rquotad(8)
rpc.rstatd(8)
rpc.rusersd(8)
rpc.rwalld(8)
rpc.sprayd(8)
rpc.statd(8)
rpc.umntall(8)
rpc.yppasswdd(8)
rpc.ypxfrd(8)
rpcbind(8)
rpcinfo(8)
rrenumd(8)
rrestore(8)
rshd(8)
rtadvd(8)
rtquery(8)
rtsol(8)
rtsold(8)
rwhod(8)
sa(8)
savecore(8)
sconfig(8)
scspd(8)
sdpcontrol(8)
sdpd(8)
securelevel(8)
sendmail(8)
setextattr(8)
setfmac(8)
setfsmac(8)
setkey(8)
setpmac(8)
sftp-server(8)
showmount(8)
shutdown(8)
sicontrol(8)
slattach(8)
slip(8)
sliplogin(8)
slstat(8)
smbmsg(8)
smrsh(8)
spkrtest(8)
spppcontrol(8)
spray(8)
ssh-keysign(8)
sshd(8)
sticky(8)
strfile(8)
sunlabel(8)
swapctl(8)
swapinfo(8)
swapoff(8)
swapon(8)
sync(8)
sysctl(8)
sysinstall(8)
syslogd(8)
talkd(8)
tcpd(8)
tcpdchk(8)
tcpdmatch(8)
tcpdrop(8)
telnetd(8)
tftpd(8)
timed(8)
timedc(8)
traceroute(8)
traceroute6(8)
trpt(8)
tunefs(8)
tzsetup(8)
ugidfw(8)
umount(8)
unstr(8)
updatedb(8)
usbd(8)
usbdevs(8)
verify_krb5_conf(8)
vinum(8)
vipw(8)
vmstat(8)
vnconfig(8)
watch(8)
watchdog(8)
watchdogd(8)
wicontrol(8)
wire-test(8)
wlconfig(8)
yp(8)
yp_mkdb(8)
ypbind(8)
ypinit(8)
yppoll(8)
yppush(8)
ypserv(8)
ypset(8)
ypxfr(8)
zdump(8)
zic(8)
zzz(8)
setkey(8)
NAME
setkey -- manually manipulate the IPsec SA/SP database
SYNOPSIS
setkey [-v] -c setkey [-v] -f filename setkey [-aPlv] -D setkey [-Pv] -F setkey [-h] -x
DESCRIPTION
The setkey utility adds, updates, dumps, or flushes Security Association Database (SAD) entries as well as Security Policy Database (SPD) entries in the kernel. The setkey utility takes a series of operations from the standard input (if invoked with -c) or the file named filename (if invoked with -f filename). -D Dump the SAD entries. If with -P, the SPD entries are dumped. -F Flush the SAD entries. If with -P, the SPD entries are flushed. -a The setkey utility usually does not display dead SAD entries with -D. If with -a, the dead SAD entries will be displayed as well. A dead SAD entry means that it has been expired but remains in the system because it is referenced by some SPD entries. -h Add hexadecimal dump on -x mode. -l Loop forever with short output on -D. -v Be verbose. The program will dump messages exchanged on PF_KEY socket, including messages sent from other processes to the ker- nel. -x Loop forever and dump all the messages transmitted to PF_KEY socket. -xx makes each timestamps unformatted. Configuration syntax With -c or -f on the command line, setkey accepts the following configu- ration syntax. Lines starting with hash signs (`#') are treated as com- ment lines. add [-46n] src dst protocol spi [extensions] algorithm ... ; Add an SAD entry. add can fail with multiple reasons, including when the key length does not match the specified algorithm. get [-46n] src dst protocol spi ; Show an SAD entry. delete [-46n] src dst protocol spi ; Remove an SAD entry. deleteall [-46n] src dst protocol ; Remove all SAD entries that match the specification. spdadd [-46n] src_range dst_range upperspec policy ; Add an SPD entry. spddelete [-46n] src_range dst_range upperspec -P direction ; Delete an SPD entry. spdflush ; Clear all SPD entries. -FP on the command line achieves the same functionality. spddump ; Dumps all SPD entries. -DP on the command line achieves the same functionality. Meta-arguments are as follows: src dst Source/destination of the secure communication is specified as IPv4/v6 address. The setkey utility can resolve a FQDN into numeric addresses. If the FQDN resolves into multiple addresses, setkey will install multiple SAD/SPD entries into the kernel by trying all possible combinations. -4, -6 and -n restricts the address resolution of FQDN in certain ways. -4 and -6 restrict results into IPv4/v6 addresses only, respectively. -n avoids FQDN resolution and requires addresses to be numeric addresses. protocol protocol is one of following: esp ESP based on rfc2406 esp-old ESP based on rfc1827 ah AH based on rfc2402 ah-old AH based on rfc1826 ipcomp IPComp tcp TCP-MD5 based on rfc2385 spi Security Parameter Index (SPI) for the SAD and the SPD. spi must be a decimal number, or a hexadecimal number with `0x' prefix. SPI values between 0 and 255 are reserved for future use by IANA and they cannot be used. TCP-MD5 associations must use 0x1000 and therefore only have per-host granularity at this time. extensions take some of the following: -m mode Specify a security protocol mode for use. mode is one of following: transport, tunnel or any. The default value is any. -r size Specify window size of bytes for replay prevention. size must be decimal number in 32-bit word. If size is zero or not specified, replay check does not take place. -u id Specify the identifier of the policy entry in SPD. See policy. -f pad_option defines the content of the ESP padding. pad_option is one of following: zero-pad All of the padding are zero. random-pad A series of randomized values are set. seq-pad A series of sequential increasing numbers Specify an encryption algorithm ealgo for ESP. -E ealgo key -A aalgo key Specify a encryption algorithm ealgo, as well as a payload authentication algorithm aalgo, for ESP. -A aalgo key Specify an authentication algorithm for AH. -C calgo [-R] Specify a compression algorithm for IPComp. If -R is specified, spi field value will be used as the IPComp CPI (compression parameter index) on wire as is. If -R is not specified, the kernel will use well-known CPI on wire, and spi field will be used only as an index for kernel internal usage. key must be double-quoted character string, or a series of hexa- decimal digits preceded by `0x'. Possible values for ealgo, aalgo and calgo are specified in sepa- rate section. src_range dst_range These are selections of the secure communication specified as IPv4/v6 address or IPv4/v6 address range, and it may accompany TCP/UDP port specification. This takes the following form: address address/prefixlen address[port] address/prefixlen[port] prefixlen and port must be decimal number. The square bracket around port is really necessary. They are not manpage metachar- acters. For FQDN resolution, the rules applicable to src and dst apply here as well. upperspec Upper-layer protocol to be used. You can use one of words in /etc/protocols as upperspec. Or icmp6, ip4, and any can be spec- ified. any stands for ``any protocol''. Also you can use the protocol number. You can specify a type and/or a code of ICMPv6 when upper-layer protocol is ICMPv6. The specification can be placed after icmp6. A type is separated with a code by single comma. A code must be specified anytime. When a zero is speci- fied, the kernel deals with it as a wildcard. Note that the ker- nel cannot distinguish a wildcard from that a type of ICMPv6 is zero. For example, the following means the policy does not require IPsec for any inbound Neighbor Solicitation: spdadd ::/0 ::/0 icmp6 135,0 -P in none; NOTE: upperspec does not work against forwarding case at this moment, as it requires extra reassembly at forwarding node (not implemented at this moment). We have many protocols in /etc/protocols, but protocols except of TCP, UDP and ICMP may not be suitable to use with IPsec. You have to consider and be care- ful to use them. indexes will be discarded. none means that IPsec operation will not take place onto the packet. ipsec means that IPsec operation will take place onto the packet. The part of protocol/mode/src-dst/level specifies the rule how to process the packet. Either ah, esp or ipcomp is to be set as protocol. mode is either transport or tunnel. If mode is tunnel, you must spec- ify the end-points addresses of the SA as src and dst with `-' between these addresses which is used to specify the SA to use. If mode is transport, both src and dst can be omitted. level is to be one of the following: default, use, require or unique. If the SA is not available in every level, the kernel will request getting SA to the key exchange daemon. default means the kernel consults to the system wide default against protocol you speci- fied, e.g., esp_trans_deflev sysctl variable, when the kernel processes the packet. use means that the kernel use a SA if it is available, otherwise the kernel keeps normal operation. require means SA is required whenever the kernel sends a packet matched with the policy. unique is the same to require. In addition, it allows the policy to bind with the unique out-bound SA. You just specify the policy level unique, racoon(8) will configure the SA for the policy. If you configure the SA by man- ual keying for that policy, you can put the decimal number as the policy identifier after unique separated by colon `:' like the following; unique:number. In order to bind this policy to the SA, number must be between 1 and 32767. It corresponds to extensions -u of the manual SA configuration. When you want to use SA bundle, you can define multiple rules. For example, if an IP header was followed by AH header followed by ESP header fol- lowed by an upper layer protocol header, the rule would be: esp/transport//require ah/transport//require; The rule order is very important. Note that ``discard'' and ``none'' are not in the syntax described in ipsec_set_policy(3). There are little differences in the syntax. See ipsec_set_policy(3) for detail.
ALGORITHMS
The following list shows the supported algorithms. protocol and algorithm are almost orthogonal. Followings are the list of authentica- tion algorithms that can be used as aalgo in -A aalgo of protocol parame- ter: algorithm keylen (bits) comment hmac-md5 128 ah: rfc2403 128 ah-old: rfc2085 hmac-sha1 160 ah: rfc2404 160 ah-old: 128bit ICV (no document) keyed-md5 128 ah: 96bit ICV (no document) 128 ah-old: rfc1828 keyed-sha1 160 ah: 96bit ICV (no document) 160 ah-old: 128bit ICV (no document) null 0 to 2048 for debugging hmac-sha2-256 256 ah: 96bit ICV (draft-ietf-ipsec-ciph-sha-256-00) 256 ah-old: 128bit ICV (no document) hmac-sha2-384 384 ah: 96bit ICV (no document) 384 ah-old: 128bit ICV (no document) hmac-sha2-512 512 ah: 96bit ICV (no document) ealgo in -E ealgo of protocol parameter: algorithm keylen (bits) comment des-cbc 64 esp-old: rfc1829, esp: rfc2405 3des-cbc 192 rfc2451 null 0 to 2048 rfc2410 blowfish-cbc 40 to 448 rfc2451 cast128-cbc 40 to 128 rfc2451 des-deriv 64 ipsec-ciph-des-derived-01 3des-deriv 192 no document rijndael-cbc 128/192/256 rfc3602 aes-ctr 160/224/288 draft-ietf-ipsec-ciph-aes-ctr-03 Note that the first 128 bits of a key for aes-ctr will be used as AES key, and remaining 32 bits will be used as nonce. Followings are the list of compression algorithms that can be used as calgo in -C calgo of protocol parameter: algorithm comment deflate rfc2394
DIAGNOSTICS
The setkey utility exits 0 on success, and >0 if an error occurs.
EXAMPLES
add 3ffe:501:4819::1 3ffe:501:481d::1 esp 123457 -E des-cbc 0x3ffe05014819ffff ; add -6 myhost.example.com yourhost.example.com ah 123456 -A hmac-sha1 "AH SA configuration!" ; add 10.0.11.41 10.0.11.33 esp 0x10001 -E des-cbc 0x3ffe05014819ffff -A hmac-md5 "authentication!!" ; get 3ffe:501:4819::1 3ffe:501:481d::1 ah 123456 ; flush ; dump esp ; spdadd 10.0.11.41/32[21] 10.0.11.33/32[any] any -P out ipsec esp/tunnel/192.168.0.1-192.168.1.2/require ; add 10.1.10.34 10.1.10.36 tcp 0x1000 -A tcp-md5 "TCP-MD5 BGP secret" ;
SEE ALSO
ipsec_set_policy(3), racoon(8), sysctl(8) Changed manual key configuration for IPsec, October 1999, http://www.kame.net/newsletter/19991007/.
HISTORY
The setkey utility first appeared in WIDE Hydrangea IPv6 protocol stack kit. The utility was completely re-designed in June 1998.
SPONSORED LINKS
Man(1) output converted with man2html , sed , awk