我一直在尝试禁止 iptables 中以 047 开头的 IP 地址,但它会将其更改为 039。
iptables -v -w -I INPUT 1 -s 047.75.162.122 -j DROP
Run Code Online (Sandbox Code Playgroud)
但是IP地址会被禁止为39.75.162.122!
你认为为什么会发生这种情况?
iwa*_*rue 24
这是正在发生的事情:
$ printf "%d\n" 047
39
Run Code Online (Sandbox Code Playgroud)
047八进制是39十进制。
您只需要删除领先的0.
猜测,这是因为 iptables 中的某些内容将 IPv4 地址拆分为 4 个十进制数字,因此它可以将 IP 字符串表示形式转换为 long。但这是猜想。
inet_aton还接受其他一些不太常用的形式(手册实际上甚至描述了它们):
octal:
020.0.1.22 -> 16.0.1.22
hexadecimal:
0x10.0.1.22 -> 16.0.1.22
combination:
020.0.1.0x16 -> 16.0.1.22
bottom two bytes together (old Class B)
16.0.278 -> 16.0.1.22
bottom three bytes together (old Class A)
16.278 -> 16.0.1.22
all in one, hex
0x10000116 -> 16.0.1.22
all in one, decimal (completely unreadable)
268435734 -> 16.0.1.22
this should be simple
0020.0426 -> ...
Run Code Online (Sandbox Code Playgroud)
它们也可能适用于网络浏览器。
八进制数以 0 为前缀,十六进制数以0x为前缀至少与 C 语言一样古老。
| 归档时间: |
|
| 查看次数: |
931 次 |
| 最近记录: |