curl
、Python
、bash
等工具提供一些使用例子 快速查询你的公网IP地址,支持IPV4和IPV6查询。
利用开放的GEOIP库,来查询指定的公网IP地理位置信息,支持多个IP批量查询。
:: Windows C:\> curl -L ip.tomoncle.com C:\> curl -L ipv6.tomoncle.com # Unix $ curl -L ip.tomoncle.com $ curl -L ipv6.tomoncle.com
Note: 当使用 ipv6.tomoncle.com
查询公网IP时,如果你的网络不支持IPV6,就会返回IPV4的地址.
Note: 如果你的系统安装了jq, 还可以这样查询 curl -s https://api.tomoncle.com/ip | jq -r '.headers."X-Real-Ip"'
:: Windows C:\> curl -s 'https://ip.tomoncle.com/v2?120.244.141.83' C:\> curl -s 'https://ip.tomoncle.com/v2/country?120.244.141.103' # Unix $ curl -s 'https://ip.tomoncle.com/v2?120.244.141.103,181.234.141.12,192.26.109.28' { "code": 200, "data": [ { "120.244.141.103": { "asn": "56048", "aso": "China Mobile Communicaitons Corporation", "iso-code": "CN", "country": "China", "country_zh": "中国", "city": "Beijing", "city_zh": "北京" } }, { "181.234.141.12": { "asn": "3816", "aso": "COLOMBIA TELECOMUNICACIONES S.A. ESP", "iso-code": "CO", "country": "Colombia", "country_zh": "哥伦比亚", "city": "Santiago de Cali", "city_zh": "卡利" } }, { "192.26.109.28": {} } ] } $ curl -s 'https://ip.tomoncle.com/v2/country?120.244.141.103' $ curl -s 'https://ip.tomoncle.com/v2/country?120.244.141.103,181.234.141.12,192.26.109.28' { "code": 200, "data": [ { "120.244.141.103": "China" }, { "181.234.141.12": "Colombia" }, { "192.26.109.28": "Finland" } ] }
Note: 支持多个IP地址查询,中间使用英文逗号分隔即可
免费开源的 HTTP REST 测试接口:支持GET, POST, HEAD, PUT, DELETE, PATCH, OPTIONS方法。
根据你发起的 HTTP 请求,返回你提交的参数,可以验证你是否正确提交参数到服务端。
:: Windows C:\> curl -s -X GET -H "Cookie:user=jack" 'https://api.tomoncle.com?size=10&pretty' C:\> curl -s -X POST -H "Cookie:user=jack" -d 'agent=app' 'https://api.tomoncle.com?size=10&pretty' # Unix $ curl -s -X POST -H "Cookie:user=jack" -d 'agent=app' 'https://api.tomoncle.com?size=10' | python -m json.tool $ curl -s -X GET -H "Cookie:user=jack" -d 'agent=alp' 'https://api.tomoncle.com/user?size=10&pretty $ curl -s -X POST -H "Content-Type:application/json" -d '{"user":"jack"}' 'https://api.tomoncle.com/acc?size=10' | python3 -m json.tool $ curl -s -X GET -H "Cookie:user=jack" 'https://api.tomoncle.com?size=10&pretty' { "code": 200, "path": "https://laurenancona.me/eks/wMy02bj5SZsNmbv12b05CazFmY6MHc0/", "method": "GET", "headers": { "Host": "api.tomoncle.com", "X-Request-Id": "d76cbf5566869baa225cbaaa711044bb", "X-Real-Ip": "126.39.52.118", "X-Forwarded-For": "126.39.52.118", "X-Forwarded-Host": "api.tomoncle.com", "X-Forwarded-Port": "443", "X-Forwarded-Proto": "https", "X-Forwarded-Scheme": "https", "X-Scheme": "https", "User-Agent": "curl/7.87.0", "Accept": "*/*", "Cookie": "user=jack" }, "args": { "size": "10", "pretty": "" } }
Note: 该接口禁止并发访问,仅提供开发、测试服务。
Note: 想格式化返回json信息,请求URL需要加pretty参数,请看Windows示例代码
以下为Linux工作中常用的脚本!包含网络测试,docker安装,源配置等等。
# Centos $ PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' # Ubuntu $ PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' $ PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' # MacOS $ PS1='%F{green}%n@%m %F{blue}%1~%f %# '
# Alpine # sed -e 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories $ sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories $ apk update # Centos $ mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak $ wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo $ wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo $ yum clean all && yum makecache # Ubuntu $ sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list $ apt update
# Centos $ set +o history && curl -s https://bash.tomoncle.com/linux-anonymous-logon.sh | bash $ cd /var/log && for i in wtmp btmp lastlog; do > $i; done && cd -
# Centos $ yum -y install epel-release net-tools ca-certificates git wget curl telnet vim sysstat
# Centos $ curl --proto '=https' --tlsv1.2 -sSf https://bash.tomoncle.com/docker-centos.sh | bash # Ubuntu $ curl --proto '=https' --tlsv1.2 -sSf https://bash.tomoncle.com/docker-ubuntu.sh | bash # Alpine $ curl --proto '=https' --tlsv1.2 -sSf https://bash.tomoncle.com/docker-alpine.sh | sh
# Centos $ rm -f /etc/machine-id && systemd-machine-id-setup $ sed -i "https://laurenancona.me/eks/wMy02bj5SZsNmbv12b05CazFmY6MHc0/UUID/c UUID=\"$(uuidgen)\"" /etc/sysconfig/network-scripts/ifcfg-ens33 $ systemctl restart network
# Unix ##################################### Centos ##################################### $ rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org $ yum -y install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm $ sed -i 's#elrepo.org/linux#mirrors.aliyun.com/elrepo#g' /etc/yum.repos.d/elrepo.repo $ sed -i 's/mirrorlist=/#mirrorlist=/g' /etc/yum.repos.d/elrepo.repo $ yum --disablerepo="*" --enablerepo="elrepo-kernel" list available $ yum -y --enablerepo=elrepo-kernel install kernel-lt $ grub2-set-default 0 $ echo -e "\033[5;36m内核已经安装成功,重启后生效\033[0m" ## 升级 kernel-header, kernel-tools kernel-tools-libs 等,请在内核升级成功后再执行 $ yum erase kernel-headers kernel-tools kernel-tools-libs $ yum -y --enablerepo=elrepo-kernel install kernel-lt* ##################################### Ubuntu #####################################
# Unix $ curl --proto '=https' --tlsv1.2 -sSf https://bash.tomoncle.com/netflow.sh | bash Linux 4.4-1160.el7.x86_64 (test) 05/21/2022 _x86_64_ (2 CPU) 12:47:15 AM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s 12:47:16 AM eth0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 12:47:16 AM eth1 84.00 0.00 4.97 0.00 0.00 0.00 0.00 12:47:16 AM eth2 1.00 0.00 0.09 0.00 0.00 0.00 0.00 12:47:16 AM lo 6.00 6.00 3.08 3.08 0.00 0.00 0.00 12:47:16 AM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s 12:47:17 AM eth0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 12:47:17 AM eth1 70.30 0.99 4.19 0.26 0.00 0.00 0.00 12:47:17 AM eth2 0.99 0.99 0.09 0.70 0.00 0.00 0.00 12:47:17 AM lo 13.86 13.86 24.42 24.42 0.00 0.00 0.00 12:47:17 AM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s 12:47:18 AM eth0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 12:47:18 AM eth1 41.00 1.00 2.48 0.74 0.00 0.00 0.00 12:47:18 AM eth2 1.00 1.00 0.09 0.70 0.00 0.00 0.00 12:47:18 AM lo 2.00 2.00 1.07 1.07 0.00 0.00 0.00
# Unix $ curl --proto '=https' --tlsv1.2 -sSf https://bash.tomoncle.com/disk.sh | bash -s create /opt/dir1 20 2022-05-21 10:26:06 INFO: 文件夹:/opt/dir1 创建成功, 配额: 20 MB $ curl --proto '=https' --tlsv1.2 -sSf https://bash.tomoncle.com/disk.sh | bash -s delete /opt/dir1 2022-05-21 10:31:01 INFO: 文件夹:/opt/dir1 删除成功!
# Python3 $ curl --proto '=https' --tlsv1.2 -sSf https://bash.tomoncle.com/binary/pip.py | python # Python2 $ curl --proto '=https' --tlsv1.2 -sSf https://bash.tomoncle.com/binary/pip2.py | python
Note: 使用指定源安装Python包:pip install --no-cache-dir xxx -i https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn
Note: 使用指定源安装Python包:cat requirements.txt | xargs -n 1 pip install --no-cache-dir -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
# Unix $ curl --proto '=https' --tlsv1.2 -sSf https://bash.tomoncle.com/cpu-limit.sh | bash -s 50
# Unix $ curl --proto '=https' --tlsv1.2 -sSf https://bash.tomoncle.com/mem-limit.sh | bash -s 500
# Unix $ curl --proto '=https' --tlsv1.2 -sSf https://bash.tomoncle.com/kill-process.sh | bash -s nginx
# Unix $ curl --proto '=https' --tlsv1.2 -sSf https://bash.tomoncle.com/certbot.sh | bash -s your.domain.com
# Unix $ curl --proto '=https' --tlsv1.2 -sSf https://bash.tomoncle.com/genpwd.sh | bash $ echo $(cat /dev/urandom | tr -cd 'a-z0-9A-Z*^%$@!_?#.' | head -c ${1:-27})
# Ubuntu $ echo "username:newpasswd" | chpasswd # Centos $ echo "newpassword" | passwd --stdin username
修复单机ES状态,只读状态等等。
:: Windows C:\> curl -H "Content-Type: application/json" \ -XPUT 'http://localhost:9200/_settings?pretty=true' \ -d '{"index":{"number_of_replicas":0}}' # Unix $ curl --proto '=https' --tlsv1.2 -sSf https://bash.tomoncle.com/es-status.sh | bash
:: Windows C:\> curl -i -X PUT -H "Content-Type:application/json" \ -d '{"index.blocks.read_only_allow_delete": null}' \ 'http://127.0.0.1:9200/_all/_settings?pretty' # Unix $ curl --proto '=https' --tlsv1.2 -sSf https://bash.tomoncle.com/es-readonly.sh | bash