Example network parameters:
This is a run-of-the-mill network config
allow-hotplug ens192
iface ens192 inet static
address 172.16.2.3/24
gateway 172.16.2.1
dns-nameservers 172.16.2.30 172.16.2.31
dns-search example.com
Configure the anycast address on the loopback. The kernel will know how to route packets from other attached interfaces to talk to any address on the loopback, packets just have to be routed to the 'public' interface to reach the address on the loopback.
In /etc/network/interfaces
auto lo
iface lo inet loopback
iface lo inet static
address 192.69.22.12/32
Using FRR, peer the server with the server's GW.
This config will advertise the defined /32 to the router with nexthop being the ens192 address.
log syslog informational
frr defaults traditional
### BGP config
debug bgp events
debug bgp filters
debug bgp fsm
debug bgp keepalives
debug bgp updates
router bgp 65102 <--(Private AS to force redistribution on router)
bgp log-neighbor-changes
bgp router-id 172.16.2.3
neighbor 172.16.2.1 remote-as 1234
neighbor 172.16.2.1 description Core-Router
neighbor 172.16.2.1 soft-reconfiguration inbound <--(Not necessary since not receiving any routes, but here just in case.)
neighbor 172.16.2.1 prefix-list Anycast out
network 192.168.100.50/32
ip prefix-list Anycast seq 10 permit 192.168.100.50/32
On the router, I setup the corresponding BGP peering config and added a prefix list to only allow accept 192.168.100.50 from the server.