Claudio Jeker <[email protected]> writes: > On Fri, Jun 21, 2019 at 02:11:53PM +0000, slackwaree wrote: >> Hello, >> >> I wonder if the following scenario can be solved with OpenBSD on 1 single >> machine or with VMM: >> >> I got 3 OpenBSD vms, all of them are exactly the same running squid except >> they use different default routers to route their traffic out. >> >> I would like to merge these to one VM if it is possible somehow to tell >> OpenBSD to use different gateway depending on the squid process. >> >> If not would the same thing be possible with VMMs? All the gateways are in >> the same IP range. >> > > A simple way to solve this is with multiple routing tables. > > Create multiple routing tables with: > route -T1 add default <gw1> > route -T2 add default <gw2> > route -T3 add default <gw3> > > And start the 3 squid processes with route -T1 exec, route -T2 exec. > You can also use the the *_rtable variable in rc.d(8) to do that > automatically. > > This requires that the 3 squids listen on different IPs or ports.
As I learned recently (investigating another issue and reading the rc.subr(8) man page), if you start these with rc scripts, you can set daemon_rtable there, as well as likely setting up the config file or port/ip address options in daemon_flags. Also be sure pexp variable is set to somthing that can differentiate the proceses or the rcctl stop/check stuff will not work. Allan

