0
点赞
收藏
分享

微信扫一扫

Linux 主机名被修改成bogon问题的几种解决办法


 



      当Linux主机名由@myhostname变成了@bogon了之后,访问网络就会出现问题,重启后也没有解决。网上搜索N久之后,发现了如下几种解决方式,特此记录一下。

 

1、在linux下添加一个127.0.0.2名叫bogon的主机
此方法使用后,bogon主机名得以解析,使用的主机名仍为bogon,但进入linux已不会再出现上述警告框。

此方法不推荐使用。

 

 

2、使用hostname命令

[root@bogon ~]# hostname  xg

[root@bogon ~]# su

[root@xg ~]# 这样既可,但可能有些linux版本下应用程序仍不能正常使用

此方法可以简单地找回你想要的主机名。

 

 

3、修改linux主机的配置文件/etc/sysconfig/network 和 /etc/hosts
     1).修改/etc/sysconfig/network里面的主机名字。
          [root@bogon ~]#  vi /etc/sysconfig/network

               NETWORKING=yes
xg                // 在这修改 hostname 为 xg
     2).修改/etc/hosts里面的名字
          [root@bogon ~]#
xg
     3).不需要重启主机,最后在终端下执行:
          [root@bogon ~]# hostname xg     // xg 为修改的hostname

xg ~]#

此方法为最根本的解决办法

 

 

4、让dns重新解析
你需要将主dns随意改一个地址保存设置,然后再改回原ip,保存设置。
注销当前用户,重新登录即可。
据说是因为dns服务器反解析私有地址时,会返回结果bogon。换一个dns解析ip就没事了 。

试过可以,但个人感觉这个弯子绕的没必要

 

 

 

 

 

备注:

bogan ['bogən] ['bəugən]

bogon是指那些不该出现在internet路由表中的地址。
这些地址应该包括:
1,私有地址如10,172.16-32,192.168…..
2,还未正式分配出去的地址

bogon定义:

Bogon is a bogus IP address and an informal name for an IP packet on the public Internet that claims to be from an area of the IP address spacereserved, but not yet allocated or delegated by the Internet Assigned Numbers Authority (IANA) or a delegated Regional Internet Registry (RIR). The areas of unallocated address space are called the bogon space.
For example, addresses from 49.0.0.0 – 49.255.255.255 have not yet been allocated.[1]
Bogons are not the same as reserved private address ranges, such as 10.x.x.x and 192.168.x.x.
Which are reserved for private networks.[2]
Many ISPs and end-user firewalls filter and block bogons, because they have no legitimate use, and usually are the result of accidental or malicious misconfiguration. Bogons can be filtered by using router ACLs, or by BGPblackholing.
IP addresses that are bogon today may not be bogon tomorrow. IANA and other registries frequently assign new address space to ISPs. Announcements of new assignments are often published on networkoperators’ mailing lists (such as NANOG) to ensure that operators have a chance to remove bogon filtering for addresses that have become legitimate.
IANA maintains a list of allocated and reserved IPv4 netblocks. [1]

除了上面的定义之外,还有一种定义的说法:

bogon就是Martians(就是私有地址和保留地址的称呼,详见RFC1918和RFC5735)和IANA未分配给RIR的并集。

这里有一份由IANA维护的IPV4分配列表

在这里可以看到 005/8就是未分配的地址,也就是bogon range。

同时还有一个概念叫做Fullbogons,它的定义范围比bogon还要大,指的是那些虽然IANA分配给RIR的地址,但是这些地址RIR没有分配给ISP或者end-user使用的地址。

所以来讲,bongon是没有什么用处的,需要在路由上设置ACL或者做BGP BLACKHOLING过滤掉

那么,我的主机名变成bogon是怎么回事又该怎么办呢?

可能是在反向解析IP时,DNS没有过滤bogon,所以把内网的IP反向解析成了bogon

所以把DNS换成一个过滤了bongon的DNS是其中一种解决办法

举报

相关推荐

0 条评论