Будет ли что-то подобное для вас работать?
const validRange = '1.1.1.1-2.2.2.2',
invalidRange = '2.2.2.2-1.1.1.1',
anotherInvalidRange = '1.1.3.1-1.1.2.1',
invalidIp = '1.1.300.1-1.1.1.1',
isRangeValid = range => {
const [rangeStart, rangeEnd] = range.split('-'),
[s1,s2,s3,s4] = rangeStart.split('.'),
[e1,e2,e3,e4] = rangeEnd.split('.')
return [s1,s2,s3,s4].some(o => o>255 || o<0) || [e1,e2,e3,e4].some(o => o>255 || o<0) ?
'range contains invalid IP' :
s1>e1 || s2>e2 || s3>e3 || s4>e4 ?
'range start is greater than range end' :
'range is valid'
}
console.log(isRangeValid(validRange))
console.log(isRangeValid(invalidRange))
console.log(isRangeValid(anotherInvalidRange))
console.log(isRangeValid(invalidIp))
.as-console-wrapper{min-height:100%;}