Yes, there is a way to take an IP address via HTML using input without using text type, like a type number. The options would require four input boxes, one for each octet.
Since there is no HTML input type that matches IPv4 address exactly and if you want to stick to a single input field type text is relatively simple with minlength, maxlength, and pattern attributes.
Bare bones HTML:
For security reasons ensure you always validate submitted data server side, not just client side. You can use same regex pattern.
* Update 3/2/2019 * Added three IPv6 address regex formats.
Only accepts IPv6 addresses in long form:
Accepts long and medium form IPv6 addresses (medium allows leading zeros):
Accepts long and medium form IPv6 addresses (medium without leading zeros):