According to the manpage of hosts_access (smb.conf refers to that), it is allowed to use wildcards ? and * in IP addresses in the option "allow hosts". Also my tests show that it actually works. But testparm says they are invalid.
sample config line: allow hosts = 192.168.1.169, 192.168.1.17?, 192.168.1.18?