1. #!/bin/bash
    2. ip=$(curl -s http://myip.ipip.net)
    3. echo "My public IP address is: $ip"

    或者直接运行

    1. curl -s myip.ipip.net
    2. # curl -s http://myip.ipip.net

    海外业务居多,推荐使用 https://myip.la