[Question]
  [
Sometimes when I'm typing out an IPv4 address, I get all the numbers right, but I forget to type one or more periods. I'd like to have a program (or function) that takes my broken IPv4 address and outputs all possible valid placements of the missing periods.
## Input
The input will always be a string that is a transformation of a valid IPv4 address (see particulars below). It will always have been transformed solely by the elimination of one or more period characters.
You submission does not need to handle inputs outside of this format.
## Output
A collection or list, in no particular order or format, of strings representing all valid IPv4 addresses that can be created from the input by the insertion of period characters into the input.
* The output may be a language-native list or other ordered or unordered collection type.
* Alternatively, it may be a string sequence of IPv4 address delimited in some clear way.
	+ If you use a single-character delimiter to delimit your string, periods and digits are not allowed as that single-character delimiter. I realize that, unlike numbers, periods as delimiters are not *ambiguous* (since every fourth period would necessarily be a delimiter) but for the sake of readability, I am disallowing it.
## IPv4 address format
While IPv4 addresses are really just a sequence of four binary octets, this challenge uses a restricted dotted decimal format.
* An IPv4 address is a four decimal values separated by three periods.
* Each of the four values are in the range `0` to `255`, inclusive.
* **Leading zeros are not allowed** in any number value. (Standalone one-character `0` is allowed; any other number beginning with a zero is not: `052`, `00`, etc.)
## Test Cases
Input is on the first line, output on second line (here, structured as a comma-separated list of quoted strings, separated by commas, surrounded by `[` `]`, but you may use any reasonable format or structure, as specified above). Some examples have notes on a third line to highlight the application of a particular rule.
```
192.168.1234
["192.168.1.234", "192.168.12.34", "192.168.123.4"]
192.1681234
["192.16.81.234", "192.168.1.234", "192.168.12.34", "192.168.123.4"]
(Note: 192.1681.2.34 (etc.) is illegal because 1681 is greater than 255)
1921681.234
["19.216.81.234", "192.16.81.234", "192.168.1.234"]
1921681234
["19.216.81.234", "192.16.81.234", "192.168.1.234", "192.168.12.34", "192.168.123.4"]
192.168.1204
["192.168.1.204", "192.168.120.4"]
(Note: 192.168.12.04 is illegal because of leading zero)
192.168.123
["1.92.168.123", "19.2.168.123", "192.1.68.123", "192.16.8.123", "192.168.1.23", "192.168.12.3"]
192.168.256
["192.168.2.56", "192.168.25.6"]
(Note: Any combination that would leave 256 intact is illegal)
120345
["1.20.3.45", "1.20.34.5", "1.203.4.5", "12.0.3.45", "12.0.34.5", "120.3.4.5"]
(Note: 12.03.4.5 (etc.) is illegal due to leading zero.)
012345
["0.1.23.45", "0.1.234.5", "0.12.3.45", "0.12.34.5", "0.123.4.5"]
(Note: the first segment must be 0, because `01` or `012` would be illegal.)
000123
["0.0.0.123"]
```
(I made these examples by hand, so please alert me to any mistakes you may find.)
  
[Answer]
# C (gcc/linux), 125 121 bytes
```
i;f(char*a){do{char*y=a,s[99],*x=inet_ntop(2,&i,s,99);for(;*x&&!(*x^*y&&*x^46);++x)y+=*x==*y;*x|*y||puts(s);}while(++i);}
```
Loops over **all** possible IPv4 addresses, and does a custom comparison that skips over extra dots in the generated ip address (but not in the main comparison address) to decide whether to print or not. **Very slow, but should finish within 1 hour on a reasonable PC**.
[Answer]
# Pyth, 24 bytes
```
f&q4lJcT\.!-J`M256jL\../
```
[Try it online](https://pyth.herokuapp.com/?code=f%26q4lJcT%5C.%21-J%60M256jL%5C..%2F&test_suite=1&test_suite_input=%22192.168.1234%22%0A%22192.1681234%22%0A%221921681.234%22%0A%221921681234%22%0A%22192.168.1204%22%0A%22192.168.123%22%0A%22192.168.256%22%0A%22120345%22%0A%22012345%22%0A%22000123%22&debug=0)
### How it works
```
                      ./Q   all partitions of input
                  jL\.      join each on .
f                           filter for results T such that:
      cT\.                    split T on .
     J                        assign to J
    l                         length
  q4                          equals 4
 &                            … and:
           -J`M256              J minus the list of representations of [0, …, 255]
          !                     is false (empty)
```
# Pyth, 17 bytes, very slow
```
@FjLL\.,^U256 4./
```
**Warning. Do not run.** Requires approximately 553 GiB of RAM.
### How it works
```
       ,             two-element list of:
        ^U256 4        all four-element lists of [0, …, 255]
               ./Q     all partitions of input
  jLL\.              join each element of both on .
@F                   fold intersection
```
[Answer]
# Perl 5, 91 bytes
```
<>=~/^(([1-9]?|1\d|2[0-4])\d|25[0-5])\.?((?1))\.?((?1))\.?((?1))$(?{print"$1.$3.$4.$5 "})^/
```
The program expects a single line of a single input and outputs space-delimited list of candidates.
### Explanation
The program exploits the backtracking feature of regex to loop over all possibilities of forming a valid IPv4 address from the input string.
```
^(([1-9]?|1\d|2[0-4])\d|25[0-5])\.?((?1))\.?((?1))\.?((?1))$
```
The IPv4 regex with optional `.`, nothing of note here.
```
(?{print"$1.$3.$4.$5 "})
```
A code evaluation expression which prints out the content of the capturing groups.
```
^
```
Make the match fails and force backtracking.
### Example run
```
$ echo "012345" | perl G89503.pl
0.12.34.5 0.12.3.45 0.1.23.45 0.1.234.5 0.123.4.5
```
[Answer]
## JavaScript (ES6), ~~147~~ ~~141~~ 135 bytes
```
f=(s,n=0)=>(a=s.split`.`)[3]?a.every(s=>s==`0`|s[0]>0&s<256)?s+' ':'':[...s].map((_,i)=>i>n?f(s.slice(0,i)+`.`+s.slice(i),i):``).join``
```
```
<input placeholder=Input oninput=o.textContent=f(this.value)><div id=o style=font-family:monospace;width:1em>Output
```
Edit: saved 6 bytes thanks to @apsillers. Saved another 6 bytes by copying @YOU's validity test.
[Answer]
# Python 3, 232 bytes
```
import re,itertools as t,ipaddress as k
R=range
i=input()
for d in R(5):
 for p in t.combinations(R(len(i)),d):
  n=i;o=0
  for a in p:n=n[:a+o]+'.'+n[a+o:];o+=1
  try:k.ip_address(n);print(n*(not re.search(r'\D?0\d',n)))
  except:0
```
Pretty simple: We place periods everywhere and print if the IP address with the periods placed is valid. We check the validity of the IP adresses by (ab)using `ipaddress.ip_address`, which raises an exception if the input is not a valid IP address. The challenge defines some additional rules that `ip_address` doesn't handle (namely, that there can be no leading zeroes), so we check for those too with a regular expression, then print.
Outputs each solution on a new line, mixed with an arbitrary number of blank lines.
Example run:
```
$ echo 012345 | python fixip.py
0.1.23.45
0.1.234.5
0.12.3.45
0.12.34.5
0.123.4.5
$ echo 000123 | python fixip.py
0.0.0.123
_
```
Here's my older, 248-byte Python 2 solution. The second and third indent levels are `\t` (raw tab) and `\t`  (raw tab plus space) respectively. This plays *really* badly with Markdown, so the tabs have been replaced by two spaces.
```
import socket,re,itertools as t
R=range
i=input()
for d in R(5):
 for p in t.combinations(R(len(i)),d):
  n=i;o=0
  for a in p:n=n[:a+o]+'.'+n[a+o:];o+=1
  try:
   socket.inet_aton(n)
   if n.count('.')==3and not re.search(r'\D?0\d',n):print n
  except:0
```
Requires the input surrounded with quotes (e.g. `"123.456.789"`). Outputs each generated IP address on a new line.
*Saved 9 bytes thanks to @grawity!*
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 110 bytes
```
:ef:{".",@N.|.}ac:3f:{@n:"."rz:cacb.}a.
,4yeN,?:N:6i.@nMl4,M:{:7&<256}a
~c[A:B]h:@N:Bc.
:ef:{,"0":"9"y:.m?}ac.
```
[Try it online!](http://brachylog.tryitonline.net/#code=OmVmOnsiLiIsQE4ufC59YWM6M2Y6e0BuOiIuInJ6OmNhY2IufWEuCiw0eWVOLD86Tjo1aS5Abk1sNCxNOns6NiY8MjU2fWEKfmNbQTpCXWg6QE46QmMuCjplZjp7LCIwIjoiOSJ5Oi5tP31hYy4&input=IjAxMjMuNDUi&args=Wg&debug=on)
[Answer]
# Python 3, ~~262~~ 260 bytes
```
p,l,L,T=set(),-1,len,tuple
while l<L(p):l=L(p);p|={T(z[:i]+(y[:j],y[j:])+z[i+1:])for z in set(p)or[T(input().split("."))]for i,y in enumerate(z)for j in range(1,L(y))}
print(['.'.join(x)for x in p if L(x)==4and all(y=='0'or y[0]!='0'and int(y)<256for y in x)])
```
No libraries used, but late and longer, may be I am missing some obvious golfing techniques.
Results anyway.
```
for x in 192.168.1234 192.1681234 1921681.234 1921681234 192.168.1204 192.168.123 192.168.256 120345 012345 000123; do
echo $x | python3 ipv4.py
done;
['192.168.123.4', '192.168.1.234', '192.168.12.34']
['192.16.81.234', '192.168.1.234', '192.168.123.4', '192.168.12.34']
['19.216.81.234', '192.168.1.234', '192.16.81.234']
['19.216.81.234', '192.168.123.4', '192.168.12.34', '192.16.81.234', '192.168.1.234']
['192.168.1.204', '192.168.120.4']
['192.16.8.123', '19.2.168.123', '1.92.168.123', '192.168.1.23', '192.168.12.3', '192.1.68.123']
['192.168.25.6', '192.168.2.56']
['1.20.3.45', '1.203.4.5', '12.0.34.5', '120.3.4.5', '1.20.34.5', '12.0.3.45']
['0.1.23.45', '0.12.3.45', '0.12.34.5', '0.123.4.5', '0.1.234.5']
['0.0.0.123']
```
]