if_ipsec(4)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ¦‹ if_ipsec(4) β€” the IPsec virtual tunneling interface πŸ¦‹

okay so this page lives in the Kernel Interfaces Manual (section 4, iykyk), and it's literally the whole glow-up guide to if_ipsec, bestie. let's get into it πŸ’…


✨ NAME ✨

if_ipsec β€” the IPsec virtual tunneling interface. it's giving route-based VPN main character energy πŸŽ€


🌸 SYNOPSIS 🌸

so the if_ipsec network interface is a whole part of the FreeBSD IPsec implementation, no cap. wanna compile it straight into the kernel? drop this line into your kernel configuration file:

options IPSEC

it can also be loaded as part of the ipsec kernel module β€” but only if your kernel was compiled with:

options IPSEC_SUPPORT

✨ see how that works? both paths are valid, just depends on your build vibe ✨


πŸ’– DESCRIPTION πŸ’–

okay so the if_ipsec network interface is targeted at creating route-based VPNs. yes bestie, route-based. it can tunnel IPv4 and IPv6 traffic over either IPv4 or IPv6, and secure the whole thing with ESP. iconic behavior honestly πŸ”₯

if_ipsec interfaces are dynamically created and destroyed with the ifconfig(8) create and destroy subcommands. you (the administrator, the main character) must configure the IPsec tunnel endpoint addresses. these addresses get used for the outer IP header of ESP packets. you can also configure the protocol and addresses for the inner IP header with ifconfig(8), and then modify the routing table so packets actually route through the if_ipsec interface. slay 🫢

when the if_ipsec interface is configured, it automatically creates special security policies. those policies can be used to acquire security associations from the IKE daemon β€” which is exactly what you need for establishing an IPsec tunnel. it's also possible to create the needed security associations manually with the setkey(8) utility. so like, automatic or handcrafted, your call πŸ’…

every if_ipsec interface has an additional numeric configuration option, reqid id. this id is used to distinguish traffic and security policies between several if_ipsec interfaces. the reqid can be specified on interface creation and changed later. if you don't specify it, it's automatically assigned. ⭐

ngl, note this: changing reqid will lead to generation of new security policies, and this may require creating new security associations. so maybe don't just casually swap it mid-vibe-check 😭

πŸŽ€ EXAMPLES πŸŽ€

the example below shows manual configuration of an IPsec tunnel between two FreeBSD hosts. host A has the IP address 192.168.0.3, and host B has the IP address 192.168.0.5. πŸ¦‹

on host A:

ifconfig ipsec0 create reqid 100
ifconfig ipsec0 inet tunnel 192.168.0.3 192.168.0.5
ifconfig ipsec0 inet 172.16.0.3/16 172.16.0.5
setkey -c
add 192.168.0.3 192.168.0.5 esp 10000 -m tunnel -u 100 -E rijndael-cbc "VerySecureKey!!1";
add 192.168.0.5 192.168.0.3 esp 10001 -m tunnel -u 100 -E rijndael-cbc "VerySecureKey!!2";
^D

on host B:

ifconfig ipsec0 create reqid 200
ifconfig ipsec0 inet tunnel 192.168.0.5 192.168.0.3
ifconfig ipsec0 inet 172.16.0.5/16 172.16.0.3
setkey -c
add 192.168.0.3 192.168.0.5 esp 10000 -m tunnel -u 200 -E rijndael-cbc "VerySecureKey!!1";
add 192.168.0.5 192.168.0.3 esp 10001 -m tunnel -u 200 -E rijndael-cbc "VerySecureKey!!2";
^D

the way this works πŸ’€ β€” note the value 100 on host A and value 200 on host B are used as reqid. the same value must be used as identifier of the policy entry in the setkey(8) command. don't mix 'em up bestie, that's the whole trick πŸ™ˆ


πŸ”₯ SEE ALSO πŸ”₯

go read them, they're all part of the squad πŸ’œ


πŸ‘‘ AUTHORS πŸ‘‘

Andrey V. Elsukov <ae@FreeBSD.org> β€” thank you icon, we appreciate you 🫢


and that's the whole page, bestie! 🌈 this cutie was brought to you by the Debian crew, dated February 6, 2017 β€” oldie but a goodie, fr fr. now go build that tunnel πŸ’…βœ¨πŸ“

πŸ“¦ where this page comes from