Hi,
I'm seeking advice on the least worst way to solve a problem I have.
I have a client that has two connections to the Internet, a 5G modem/router and an aDSL modem/router. The 5G is for outgoing connections (www, email, all that jazz) and the aDSL service is for incoming SSH connections. These connections are to a FreeBSD box.
The 5G modem/router is from Telstra (the big telco in Australia if you're not familiar with them) and it has no port forwarding or static routing capability (in 2024, really?!) and they do not provide a static IP address no matter how much you ask them to do so. I feel kinda privilegded that it lets you change DHCP settings ... and turn DhCP off! Anyway, that's a rant for another place. I need a solution!
The aDSL service has a static IP and I can (and do!) port forward from it to the FreeBSD box for incoming SSH for management etc.
At the moment, I have both these devices on the same physical ethernet and IP network (192.168.0.0/24), the aDSL is 192.168.0.1, the 5G is 192.168.0.254 and the FreeBSD box is 192.168.0.2. As above, the aDSL device is port forwarding AND NAT'ing SSH for access to the FreeBSD box (currently FreeBSD 14.1). I could add an extra ethernet port to the FreeBSD box if required.
The FreeBSD box is working as a router for IPv4 and IPv6 (or it will, once I get it to behave with IPv6) and is running PF as a NAT service so devices on the inside (192.168.1.0/24) can get out. It's basically a firewall/router at the moment.
I need to be able to run almost everything via the 5G device, except ssh to and from the FreeBSD box (but not any other devices on the other side of the FreeBSD box). I can do a dodgey with a static route if I know where the ssh connection is coming from, but that only works as a proof of concept and will not scale to more than a device or two, and I need to support access in via SSH from IP addresses that I cannot predict.
I've gone down the rabbit hole of using PF's route-to, but groveling around whatever examples I can find online suggests that this will only work for traffic passing through the FreeBSD box, not arriving at it as its endpoint.
PF config looks like this :
Various pokes at that ruleset have only resulted in "syntax error" on line 26, or 25, etc. But as above, I don't think this will work anyway.
Essentially I need a default route for sshd on the box itself, and no-where else.
I've had a quick look at some references to using multiple routing tables :
https://mmacleod.ca/2011/06/source-based-routing-with-freebsd-using-multiple-routing-table/
But that's old and I'm not sure that it's viable these days?
I'm considering spinning up a virtual machine on the box just to be an SSH entry point and giving it its own routing table, but that's pretty cumbersome for this, is there a better way?
Can anyone here suggest the least worst way to get this to work?
I'm seeking advice on the least worst way to solve a problem I have.
I have a client that has two connections to the Internet, a 5G modem/router and an aDSL modem/router. The 5G is for outgoing connections (www, email, all that jazz) and the aDSL service is for incoming SSH connections. These connections are to a FreeBSD box.
The 5G modem/router is from Telstra (the big telco in Australia if you're not familiar with them) and it has no port forwarding or static routing capability (in 2024, really?!) and they do not provide a static IP address no matter how much you ask them to do so. I feel kinda privilegded that it lets you change DHCP settings ... and turn DhCP off! Anyway, that's a rant for another place. I need a solution!
The aDSL service has a static IP and I can (and do!) port forward from it to the FreeBSD box for incoming SSH for management etc.
At the moment, I have both these devices on the same physical ethernet and IP network (192.168.0.0/24), the aDSL is 192.168.0.1, the 5G is 192.168.0.254 and the FreeBSD box is 192.168.0.2. As above, the aDSL device is port forwarding AND NAT'ing SSH for access to the FreeBSD box (currently FreeBSD 14.1). I could add an extra ethernet port to the FreeBSD box if required.
The FreeBSD box is working as a router for IPv4 and IPv6 (or it will, once I get it to behave with IPv6) and is running PF as a NAT service so devices on the inside (192.168.1.0/24) can get out. It's basically a firewall/router at the moment.
I need to be able to run almost everything via the 5G device, except ssh to and from the FreeBSD box (but not any other devices on the other side of the FreeBSD box). I can do a dodgey with a static route if I know where the ssh connection is coming from, but that only works as a proof of concept and will not scale to more than a device or two, and I need to support access in via SSH from IP addresses that I cannot predict.
I've gone down the rabbit hole of using PF's route-to, but groveling around whatever examples I can find online suggests that this will only work for traffic passing through the FreeBSD box, not arriving at it as its endpoint.
PF config looks like this :
Code:
# NAT for Telstra 5G
#
# $Id: pf.conf,v 1.2 2024/11/20 23:27:40 carl Exp carl $
#
# [URL]https://docs.freebsd.org/en/books/handbook/firewalls/#firewalls-pf[/URL]
ext_if="re1"
int_if="re0"
localnet=$int_if:network
ADSL="192.168.0.1"
client_services = "{ ssh, smtp, smtps, submission, domain, www, \
http, https, pop3, auth, pop3s, imap, imaps, ftp }"
udp_services = "{ domain, submission, ntp }"
#pass from re0:network to any port $ports keep state
# this is the NAT part, if the STOOPID Telstra G5 router could do static
# routes, this would not be necessary!
nat on $ext_if from $localnet to any -> ($ext_if)
#nat on $ext_if inet6 from $localnet to any -> ($ext_if)
# manage the GW from remote
# pass in inet proto tcp to $ext_if port ssh keep state
#pass in quick inet proto tcp on $ext_if from any to 192.168.0.2 port ssh tag MGT
pass in quick on $ext_if from any to 192.168.0.2 tag MGT
#pass out quick tagged MGT route-to ($ext_if $ADSL)
Various pokes at that ruleset have only resulted in "syntax error" on line 26, or 25, etc. But as above, I don't think this will work anyway.
Essentially I need a default route for sshd on the box itself, and no-where else.
I've had a quick look at some references to using multiple routing tables :
https://mmacleod.ca/2011/06/source-based-routing-with-freebsd-using-multiple-routing-table/
But that's old and I'm not sure that it's viable these days?
I'm considering spinning up a virtual machine on the box just to be an SSH entry point and giving it its own routing table, but that's pretty cumbersome for this, is there a better way?
Can anyone here suggest the least worst way to get this to work?