![如何将这个小脚本从 IPv4 调整为 IPv6?](https://linux22.com/image/102004/%E5%A6%82%E4%BD%95%E5%B0%86%E8%BF%99%E4%B8%AA%E5%B0%8F%E8%84%9A%E6%9C%AC%E4%BB%8E%20IPv4%20%E8%B0%83%E6%95%B4%E4%B8%BA%20IPv6%EF%BC%9F.png)
该脚本正在检查谁在敲电话线,并通过 whois 显示想要敲电话线的人的地址。
awk '{
for (i = 1; i <= NF; i++)
if ($i ~ /^SRC=/)
print substr($i, 5)
}' /var/log/syslog | sort -u | while read ip; #former file was: /etc/sysconfig/syslog
do
printf ' INVALID STATE ' && printf ' === %s ===\n' "$ip"
whois "$ip" >> output-001.txt;
done
此脚本适用于 IPv4 地址,但不适用于 IPv6——我需要如何调整它才能同时适用于两者?我需要每个试图敲电话线的人的 whois 地址。
的内容output-001.txt
是:
未知的 AS 编号或未知的 ip 网络。请升级此程序 (whois)。
我认为这是因为提供商的防火墙阻止了脚本。我可以添加什么来通过提供商(unitymedia)的防火墙?
对于 roaima - 2016 年夏季的结果在 output-001.txt 中如下所示:
% This is the RIPE Database query service.
% The objects are in RPSL format.
%
% The RIPE Database is subject to Terms and Conditions.
% See http://www.ripe.net/db/support/db-terms-conditions.pdf
% Note: this output has been filtered.
% To receive output for a database update, use the "-B" flag.
% Information related to '2a02:908::/32'
% Abuse contact for '2a02:908::/32' is '[email protected]'
inet6num: 2a02:908::/32
netname: DE-KNRW-20090121
country: DE
org: ORG-iGCK3-RIPE
admin-c: UMAC-RIPE
tech-c: UMTC-RIPE
status: ALLOCATED-BY-RIR
mnt-by: RIPE-NCC-HM-MNT
mnt-lower: UNITYMEDIA-MNT
mnt-routes: UNITYMEDIA-MNT
mnt-domains: UNITYMEDIA-MNT
created: 2009-01-21T09:36:59Z
last-modified: 2016-04-14T09:45:51Z
source: RIPE # Filtered
remarks: Contact data for any network abuse/spam/security issue:
remarks: [email protected]
remarks: =======================================================
remarks: Contact data for any legal/law enforcement inquiries:
remarks: Auskunft.UM (at) unitymedia.de
remarks: Fax: 49 2273 5947 3220 (primary)
remarks: Fax: 49 2273 5947 2251 (backup)
organisation: ORG-iGCK3-RIPE
org-name: Unitymedia NRW GmbH
org-type: LIR
address: Aachener Str. 746 - 750
address: 50933
address: Koeln
address: GERMANY
phone: +49 2273 605 8567
fax-no: +49 2273 5947 2251
fax-no: +49 2273 605 4339
abuse-mailbox: [email protected]
admin-c: SB666-RIPE
admin-c: JK8125-RIPE
admin-c: MH3982-RIPE
mnt-ref: RIPE-NCC-HM-MNT
mnt-ref: UNITYMEDIA-MNT
mnt-by: RIPE-NCC-HM-MNT
abuse-c: UKAD1-RIPE
created: 2004-04-17T11:09:24Z
last-modified: 2016-03-11T12:07:57Z
source: RIPE # Filtered
role: Unitymedia Administration
address: Unitymedia Group
Aachener Strasse 746-750
50933 Koeln
Germany
admin-c: EM572-RIPE
tech-c: UMTC-RIPE
nic-hdl: UMAC-RIPE
remarks: =====================================================
remarks: Contact data for any legal/law enforcement inquiries:
remarks: Auskunft.UM (at) unitymedia.de
remarks: Fax: +49 2273 5947 3220 (primary)
remarks: Fax: +49 2273 5947 2251 (backup)
remarks: =====================================================
abuse-mailbox: [email protected]
mnt-by: UNITYMEDIA-MNT
created: 2009-07-10T11:13:10Z
last-modified: 2009-09-03T09:14:51Z
source: RIPE # Filtered
role: Unitymedia Technical Contact
address: Unitymedia KabelBW GmbH
address: Michael-Schumacher-Strasse 1
address: 50170 Kerpen
address: DE
admin-c: UMAC-RIPE
tech-c: MH3982-RIPE
tech-c: SJ3189-RIPE
tech-c: EM10466-RIPE
nic-hdl: UMTC-RIPE
remarks: =====================================================
remarks: Contact data for any legal/law enforcement inquiries:
remarks: Auskunft.UM (at) unitymedia.de
remarks: Fax: +49 2273 5947 3220 (primary)
remarks: Fax: +49 2273 5947 2251 (backup)
remarks: =====================================================
abuse-mailbox: [email protected]
mnt-by: UNITYMEDIA-MNT
created: 2009-07-10T11:13:10Z
last-modified: 2014-11-19T06:01:06Z
source: RIPE # Filtered
% Information related to '2a02:908:8000::/33AS20825'
route6: 2a02:908:8000::/33
descr: Unitymedia
origin: AS20825
mnt-by: UNITYMEDIA-MNT
created: 2016-02-11T13:24:04Z
last-modified: 2016-02-11T13:25:00Z
source: RIPE
% Information related to '2a02:908:8000::/33AS6830'
route6: 2a02:908:8000::/33
descr: Unitymedia
origin: AS6830
mnt-by: UNITYMEDIA-MNT
created: 2016-02-11T14:58:12Z
last-modified: 2016-02-11T14:58:12Z
source: RIPE
% This query was served by the RIPE Database Query Service version 1.87.4 (BLAARKOP)
% This is the RIPE Database query service.
% The objects are in RPSL format.
%
% The RIPE Database is subject to Terms and Conditions.
% See http://www.ripe.net/db/support/db-terms-conditions.pdf
% Note: this output has been filtered.
% To receive output for a database update, use the "-B" flag.
% Information related to '2a02:908::/32'
% Abuse contact for '2a02:908::/32' is '[email protected]'
inet6num: 2a02:908::/32
netname: DE-KNRW-20090121
country: DE
org: ORG-iGCK3-RIPE
admin-c: UMAC-RIPE
tech-c: UMTC-RIPE
status: ALLOCATED-BY-RIR
mnt-by: RIPE-NCC-HM-MNT
mnt-lower: UNITYMEDIA-MNT
mnt-routes: UNITYMEDIA-MNT
mnt-domains: UNITYMEDIA-MNT
created: 2009-01-21T09:36:59Z
last-modified: 2016-04-14T09:45:51Z
source: RIPE # Filtered
remarks: Contact data for any network abuse/spam/security issue:
remarks: [email protected]
remarks: =======================================================
remarks: Contact data for any legal/law enforcement inquiries:
remarks: Auskunft.UM (at) unitymedia.de
remarks: Fax: 49 2273 5947 3220 (primary)
remarks: Fax: 49 2273 5947 2251 (backup)
organisation: ORG-iGCK3-RIPE
org-name: Unitymedia NRW GmbH
org-type: LIR
address: Aachener Str. 746 - 750
address: 50933
address: Koeln
address: GERMANY
phone: +49 2273 605 8567
fax-no: +49 2273 5947 2251
fax-no: +49 2273 605 4339
abuse-mailbox: [email protected]
admin-c: SB666-RIPE
admin-c: JK8125-RIPE
admin-c: MH3982-RIPE
mnt-ref: RIPE-NCC-HM-MNT
mnt-ref: UNITYMEDIA-MNT
mnt-by: RIPE-NCC-HM-MNT
abuse-c: UKAD1-RIPE
created: 2004-04-17T11:09:24Z
last-modified: 2016-03-11T12:07:57Z
source: RIPE # Filtered
role: Unitymedia Administration
address: Unitymedia Group
Aachener Strasse 746-750
50933 Koeln
Germany
admin-c: EM572-RIPE
tech-c: UMTC-RIPE
nic-hdl: UMAC-RIPE
remarks: =====================================================
remarks: Contact data for any legal/law enforcement inquiries:
remarks: Auskunft.UM (at) unitymedia.de
remarks: Fax: +49 2273 5947 3220 (primary)
remarks: Fax: +49 2273 5947 2251 (backup)
remarks: =====================================================
abuse-mailbox: [email protected]
mnt-by: UNITYMEDIA-MNT
created: 2009-07-10T11:13:10Z
last-modified: 2009-09-03T09:14:51Z
source: RIPE # Filtered
role: Unitymedia Technical Contact
address: Unitymedia KabelBW GmbH
address: Michael-Schumacher-Strasse 1
address: 50170 Kerpen
address: DE
admin-c: UMAC-RIPE
tech-c: MH3982-RIPE
tech-c: SJ3189-RIPE
tech-c: EM10466-RIPE
nic-hdl: UMTC-RIPE
remarks: =====================================================
remarks: Contact data for any legal/law enforcement inquiries:
remarks: Auskunft.UM (at) unitymedia.de
remarks: Fax: +49 2273 5947 3220 (primary)
remarks: Fax: +49 2273 5947 2251 (backup)
remarks: =====================================================
abuse-mailbox: [email protected]
mnt-by: UNITYMEDIA-MNT
created: 2009-07-10T11:13:10Z
last-modified: 2014-11-19T06:01:06Z
source: RIPE # Filtered
% Information related to '2a02:908:8000::/33AS20825'
route6: 2a02:908:8000::/33
descr: Unitymedia
origin: AS20825
mnt-by: UNITYMEDIA-MNT
created: 2016-02-11T13:24:04Z
last-modified: 2016-02-11T13:25:00Z
source: RIPE
% Information related to '2a02:908:8000::/33AS6830'
route6: 2a02:908:8000::/33
descr: Unitymedia
origin: AS6830
mnt-by: UNITYMEDIA-MNT
created: 2016-02-11T14:58:12Z
last-modified: 2016-02-11T14:58:12Z
source: RIPE
% This query was served by the RIPE Database Query Service version 1.87.4 (ANGUS)
Unbekannte AS-Nummer oder unbekanntes IP-Netzwerk. Bitte führen Sie ein Upgrade dieses Programms durch.
% This is the RIPE Database query service.
% The objects are in RPSL format.
%
% The RIPE Database is subject to Terms and Conditions.
% See http://www.ripe.net/db/support/db-terms-conditions.pdf
% Note: this output has been filtered.
% To receive output for a database update, use the "-B" flag.
% Information related to '2a02:908::/32'
% Abuse contact for '2a02:908::/32' is '[email protected]'
inet6num: 2a02:908::/32
netname: DE-KNRW-20090121
country: DE
org: ORG-iGCK3-RIPE
admin-c: UMAC-RIPE
tech-c: UMTC-RIPE
status: ALLOCATED-BY-RIR
mnt-by: RIPE-NCC-HM-MNT
mnt-lower: UNITYMEDIA-MNT
mnt-routes: UNITYMEDIA-MNT
mnt-domains: UNITYMEDIA-MNT
created: 2009-01-21T09:36:59Z
last-modified: 2016-04-14T09:45:51Z
source: RIPE # Filtered
remarks: Contact data for any network abuse/spam/security issue:
remarks: [email protected]
remarks: =======================================================
remarks: Contact data for any legal/law enforcement inquiries:
remarks: Auskunft.UM (at) unitymedia.de
remarks: Fax: 49 2273 5947 3220 (primary)
remarks: Fax: 49 2273 5947 2251 (backup)
organisation: ORG-iGCK3-RIPE
org-name: Unitymedia NRW GmbH
org-type: LIR
address: Aachener Str. 746 - 750
address: 50933
address: Koeln
address: GERMANY
phone: +49 2273 605 8567
fax-no: +49 2273 5947 2251
fax-no: +49 2273 605 4339
abuse-mailbox: [email protected]
admin-c: SB666-RIPE
admin-c: JK8125-RIPE
admin-c: MH3982-RIPE
mnt-ref: RIPE-NCC-HM-MNT
mnt-ref: UNITYMEDIA-MNT
mnt-by: RIPE-NCC-HM-MNT
abuse-c: UKAD1-RIPE
created: 2004-04-17T11:09:24Z
last-modified: 2016-03-11T12:07:57Z
source: RIPE # Filtered
role: Unitymedia Administration
address: Unitymedia Group
Aachener Strasse 746-750
50933 Koeln
Germany
admin-c: EM572-RIPE
tech-c: UMTC-RIPE
nic-hdl: UMAC-RIPE
remarks: =====================================================
remarks: Contact data for any legal/law enforcement inquiries:
remarks: Auskunft.UM (at) unitymedia.de
remarks: Fax: +49 2273 5947 3220 (primary)
remarks: Fax: +49 2273 5947 2251 (backup)
remarks: =====================================================
abuse-mailbox: [email protected]
mnt-by: UNITYMEDIA-MNT
created: 2009-07-10T11:13:10Z
last-modified: 2009-09-03T09:14:51Z
source: RIPE # Filtered
role: Unitymedia Technical Contact
address: Unitymedia KabelBW GmbH
address: Michael-Schumacher-Strasse 1
address: 50170 Kerpen
address: DE
admin-c: UMAC-RIPE
tech-c: MH3982-RIPE
tech-c: SJ3189-RIPE
tech-c: EM10466-RIPE
nic-hdl: UMTC-RIPE
remarks: =====================================================
remarks: Contact data for any legal/law enforcement inquiries:
remarks: Auskunft.UM (at) unitymedia.de
remarks: Fax: +49 2273 5947 3220 (primary)
remarks: Fax: +49 2273 5947 2251 (backup)
remarks: =====================================================
abuse-mailbox: [email protected]
mnt-by: UNITYMEDIA-MNT
created: 2009-07-10T11:13:10Z
last-modified: 2014-11-19T06:01:06Z
source: RIPE # Filtered
% Information related to '2a02:908:8000::/33AS20825'
答案1
使用输出文件中的第一个 IPv6 地址,如果我只是
$whois 2a02:908::/32
我得到了预期的结果,没有 whois 错误(未知 AS 编号或未知 ip 网络。请升级此程序 (whois)。)
$whois 2a02:908::/32
% This is the RIPE Database query service.
% The objects are in RPSL format.
%
% The RIPE Database is subject to Terms and Conditions.
% See http://www.ripe.net/db/support/db-terms-conditions.pdf
% Note: this output has been filtered.
% To receive output for a database update, use the "-B" flag.
% Information related to '2a02:908::/32'
% Abuse contact for '2a02:908::/32' is '[email protected]'
inet6num: 2a02:908::/32
netname: DE-KNRW-20090121
country: DE
org: ORG-iGCK3-RIPE
admin-c: UMAC-RIPE
tech-c: UMTC-RIPE
status: ALLOCATED-BY-RIR
remarks: Contact data for any network abuse/spam/security issue:
remarks: [email protected]
remarks: =======================================================
remarks: Contact data for any legal/law enforcement inquiries:
remarks: Auskunft.UM (at) unitymedia.de
remarks: Fax: 49 2273 5947 3220 (primary)
remarks: Fax: 49 2273 5947 2251 (backup)
mnt-by: RIPE-NCC-HM-MNT
mnt-by: UNITYMEDIA-MNT
mnt-lower: UNITYMEDIA-MNT
mnt-routes: UNITYMEDIA-MNT
mnt-domains: UNITYMEDIA-MNT
created: 2009-01-21T09:36:59Z
last-modified: 2016-08-25T14:02:54Z
source: RIPE # Filtered
organisation: ORG-iGCK3-RIPE
org-name: Unitymedia NRW GmbH
org-type: LIR
address: Aachener Str. 746 - 750
address: 50933
address: Koeln
address: GERMANY
phone: +49 2273 605 8567
fax-no: +49 2273 5947 2251
fax-no: +49 2273 605 4339
admin-c: SB666-RIPE
admin-c: JK8125-RIPE
admin-c: MH3982-RIPE
abuse-c: UKAD1-RIPE
mnt-ref: RIPE-NCC-HM-MNT
mnt-ref: UNITYMEDIA-MNT
abuse-mailbox: [email protected]
mnt-by: RIPE-NCC-HM-MNT
mnt-by: UNITYMEDIA-MNT
created: 2004-04-17T11:09:24Z
last-modified: 2016-08-25T14:03:26Z
source: RIPE # Filtered
role: Unitymedia Administration
address: Unitymedia Group
Aachener Strasse 746-750
50933 Koeln
Germany
admin-c: EM572-RIPE
tech-c: UMTC-RIPE
nic-hdl: UMAC-RIPE
remarks: =====================================================
remarks: Contact data for any legal/law enforcement inquiries:
remarks: Auskunft.UM (at) unitymedia.de
remarks: Fax: +49 2273 5947 3220 (primary)
remarks: Fax: +49 2273 5947 2251 (backup)
remarks: =====================================================
abuse-mailbox: [email protected]
mnt-by: UNITYMEDIA-MNT
created: 2009-07-10T11:13:10Z
last-modified: 2009-09-03T09:14:51Z
source: RIPE # Filtered
role: Unitymedia Technical Contact
address: Unitymedia KabelBW GmbH
address: Michael-Schumacher-Strasse 1
address: 50170 Kerpen
address: DE
admin-c: UMAC-RIPE
tech-c: MH3982-RIPE
tech-c: SJ3189-RIPE
tech-c: EM10466-RIPE
nic-hdl: UMTC-RIPE
remarks: =====================================================
remarks: Contact data for any legal/law enforcement inquiries:
remarks: Auskunft.UM (at) unitymedia.de
remarks: Fax: +49 2273 5947 3220 (primary)
remarks: Fax: +49 2273 5947 2251 (backup)
remarks: =====================================================
abuse-mailbox: [email protected]
mnt-by: UNITYMEDIA-MNT
created: 2009-07-10T11:13:10Z
last-modified: 2014-11-19T06:01:06Z
source: RIPE # Filtered
% Information related to '2a02:908::/32AS20825'
route6: 2a02:908::/32
descr: Unitymedia
origin: AS20825
mnt-by: UNITYMEDIA-MNT
created: 2009-01-23T22:05:02Z
last-modified: 2009-07-10T15:01:59Z
source: RIPE
% Information related to '2a02:908::/32AS6830'
route6: 2a02:908::/32
descr: Unitymedia
origin: AS6830
mnt-by: UNITYMEDIA-MNT
created: 2016-02-11T14:56:17Z
last-modified: 2016-02-11T14:56:17Z
source: RIPE
% This query was served by the RIPE Database Query Service version 1.88 (BLAARKOP)
此消息提示您更新您的 whois 程序。
您最近是否尝试过更新/升级您的 whois 程序?