not needed to do copy and also `start_with?` is better
so It can looks like ( both lines )

```ruby
ls.reject! do |address|
  address.start_with? "127." || # local IPv4
     address.start_with? "::1" # local IPv6
end
```

BTW one more idea (that is fail of old code). Your variable is still called ls which is quite unintuitive name and lives really long. It would be nice to rename it after some map operation because now it is now result of ls, but more likely list of ips.