energywu 发表于 2015-07-23 12:24

icmp的问题

本帖最后由 energywu 于 2015-07-23 12:31 编辑

host unreachable

发udp unicast packet, 由于某种原因拿不到对应ip的mac,所以包发不出去。
但是什么地方会发ICMP包?应用层么?
还是kernel什么地方,找了下,没发现什么地方会发这种包啊。
请大虾们指教。
非常感激。

energywu 发表于 2015-07-23 12:44

顶起来。。。

framily 发表于 2015-07-23 16:42

顶起来         

apen 发表于 2015-07-25 16:16

"ICMP是“Internet Control Message Protocol”(Internet控制消息协议)的缩写。它是TCP/IP协议族的一个子协议,用于在IP主机、路由器之间传递控制消息。控制消息是指网络通不通、主机是否可达、路由是否可用等网络本身的消息。" host unreachable也是它的工作内容之一。

su8610 发表于 2015-07-25 17:20

回复 1# energywu


    不知道你说的什么意思。但是iptable可以添加一个规则,就是-j reject --reject-with ,你说的有点类似这种情况,看看你的iptable里面有没有这样的规则

       --reject-with type
            Thetypegiven can be icmp-net-unreachable, icmp-host-unreach-
            able,       icmp-port-unreachable,       icmp-proto-unreachable,
            icmp-net-prohibited,icmp-host-prohibited or icmp-admin-prohib-
            ited(*)whichreturntheappropriateICMPerrormessage
            (port-unreachableis the default).The option tcp-reset can be
            used on rules which only match the TCP protocol: thiscausesa
            TCPRSTpackettobesentback.This is mainly useful for
            blocking ident (113/tcp)probeswhichfrequentlyoccurwhen
            sendingmail to broken mail hosts (which won’t accept your mail
            otherwise).

       (*) Using icmp-admin-prohibited with kernels thatdonotsupportit
       will result in a plain DROP instead of REJECT

ssffzz1 发表于 2015-07-28 12:14

没看懂什么意思啊。
LZ详细说下。

ken1980 发表于 2015-07-28 14:28

/linux/net/ipv4/route.c

static int ip_error(struct sk_buff *skb)
{
        struct rtable *rt = skb_rtable(skb);
        unsigned long now;
        int code;

        switch (rt->u.dst.error) {
                case EINVAL:
                default:
                        goto out;
                case EHOSTUNREACH:
                        code = ICMP_HOST_UNREACH;
                        break;
                case ENETUNREACH:
                        code = ICMP_NET_UNREACH;
                        IP_INC_STATS_BH(dev_net(rt->u.dst.dev),
                                        IPSTATS_MIB_INNOROUTES);
                        break;
                case EACCES:
                        code = ICMP_PKT_FILTERED;
                        break;
        }

        now = jiffies;
        rt->u.dst.rate_tokens += now - rt->u.dst.rate_last;
        if (rt->u.dst.rate_tokens > ip_rt_error_burst)
                rt->u.dst.rate_tokens = ip_rt_error_burst;
        rt->u.dst.rate_last = now;
        if (rt->u.dst.rate_tokens >= ip_rt_error_cost) {
                rt->u.dst.rate_tokens -= ip_rt_error_cost;
                icmp_send(skb, ICMP_DEST_UNREACH, code, 0);
        }

out:        kfree_skb(skb);
        return 0;
}
页: [1]
查看完整版本: icmp的问题