大网数据广告活动
服务器运维问答

iptables is changing IP addresses that start with 047. to 39.!

· 52CE 我爱测

I have been trying to ban an IP address in iptables that starts with 047, but it would change it to 039. iptables -v -w -I INPUT 1 -s 047.75.162.122 -j DROP But the IP address would be banned as 39.75.162.122! Why do you think th…

问题原文

原帖链接 · Talal Al-Khalifa · CC BY-SA 3.0

I have been trying to ban an IP address in iptables that starts with 047, but it would change it to 039.

iptables -v -w -I INPUT 1 -s 047.75.162.122 -j DROP

But the IP address would be banned as 39.75.162.122!

Why do you think this is happening?

社区高分解答

原帖链接 · ilkkachu · CC BY-SA 3.0

inet_aton also accepts a couple of other less usual forms (the manual actually even describes them):

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      ->  ...

They're likely to work on web browsers too.

Prefixing octal numbers with a zero, and hexadecimal numbers with 0x is at least as old as the C language.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-03-10)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。