Last Updated: February 25, 2016
·
2.741K
· andersbrownwort

SQL to Generate Random IP Address

Generate a fake IP address - helpful generating test data.

SELECT CONCAT(
  TRUNC(RANDOM() * 250 + 2), '.' , 
  TRUNC(RANDOM() * 250 + 2), '.', 
  TRUNC(RANDOM() * 250 + 2), '.',
  TRUNC(RANDOM() * 250 + 2)
)::INET;