Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux shell batch query source ip

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

# due to blog format problems, some characters are not displayed and screenshots have been taken

#! / bin/bash

For i in cat ip.txt

Do

Ip_address=curl-A "Mozilla/5.0 (X11; Linux x86x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36"-s "http://ip138.com/ips138.asp?ip="$i"&action=2" | iconv-f gb2312-t utf-8 | grep" Local data "| awk-F' |'{print $2}'"

Echo-e $I $ip_address > > source_ip.txt

Done

# simple script

#! / bin/bash

For i in cat ip.txt

Do

Source_city=curl-s http://ip-api.com/json/$i?lang=zh-CN | awk-Fidelje'{print $6}'

Echo $I $source_city > source_ip.txt

Done

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report