当前位置:   article > 正文

调试 L2TP问题 avp is incorrect size 8

调试 L2TP问题 avp is incorrect size 8

调试 L2TP问题 (result_code_avp: avp is incorrect size. 8 < 10)

1. 测试环境:AR9341的路由器

2. 内核版本:3.3.8/3.18.23

3. L2TP VPN使用版本

~ # 
~ # pppd -v
pppd: unrecognized option '-v'
pppd version 2.4.7
Usage: pppd [ options ], where options are:
        <device>        Communicate over the named device
        <speed>         Set the baud rate to <speed>
        <loc>:<rem>     Set the local and/or remote interface IP
                        addresses.  Either one may be omitted.
        asyncmap <n>    Set the desired async map to hex <n>
        auth            Require authentication from peer
        connect <p>     Invoke shell command <p> to set up the serial line
        crtscts         Use hardware RTS/CTS flow control
        defaultroute    Add default route through interface
        file <f>        Take options from file <f>
        modem           Use modem control lines
        mru <n>         Set MRU value to <n> for negotiation
See pppd(8) for more options.
~ # 
~ # xl2tpd -v

xl2tpd version:  xl2tpd-1.3.12
~ # 
~ # uname -an
Linux (tozedap-p59) 3.3.8 #1 Thu Aug 16 08:56:34 CST 2018 mips GNU/Linux
~ # 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26

4. 问题描述

  • L2TP连接自己在linux搭建的服务器或者TP-link的企业路由器,都是可以成功。但是连接H3C的一个服务器时,出现拨号失败的问题。详细记录如下:

1)xl2tpd的调试信息如下:

~ # xl2tpd -c /tmp/xl2tpd/xl2tpd.conf -D
xl2tpd[3173]: setsockopt recvref[30]: Protocol not available
xl2tpd[3173]: Using l2tp kernel support.
xl2tpd[3173]: xl2tpd version xl2tpd-1.3.7 started on (tozedap-p59) PID:3173
xl2tpd[3173]: Written by Mark Spencer, Copyright (C) 1998, Adtran, Inc.
xl2tpd[3173]: Forked by Scott Balmos and David Stipp, (C) 2001
xl2tpd[3173]: Inherited by Jeff McAdams, (C) 2002
xl2tpd[3173]: Forked again by Xelerance (www.xelerance.com) (C) 2006-2016
xl2tpd[3173]: Listening on IP address 0.0.0.0, port 1701
xl2tpd[3173]: Connecting to host 113.98.195.201, port 1701
xl2tpd[3173]: Connection established to 113.98.195.201, 1701.  Local: 41329, Remote: 12670 (ref=0/0).
xl2tpd[3173]: Calling on tunnel 41329
xl2tpd[3173]: Call established with 113.98.195.201, Local: 64329, Remote: 40433, Serial: 1 (ref=0/0)
xl2tpd[3173]: start_pppd: I'm running: 
xl2tpd[3173]: "/usr/sbin/pppd" 
xl2tpd[3173]: "plugin" 
xl2tpd[3173]: "pppol2tp.so" 
xl2tpd[3173]: "pppol2tp" 
xl2tpd[3173]: "7" 
xl2tpd[3173]: "passive" 
xl2tpd[3173]: "nodetach" 
xl2tpd[3173]: ":" 
xl2tpd[3173]: "file" 
xl2tpd[3173]: "/tmp/xl2tpd/options.l2tpd.lac" 
xl2tpd[3173]: result_code_avp: avp is incorrect size.  8 < 10
xl2tpd[3173]: handle_avps: Bad exit status handling attribute 1 (Result Code) on mandatory packet.
xl2tpd[3173]: call_close: Call 64329 to 113.98.195.201 disconnected
^Cxl2tpd[3173]: death_handler: Fatal signal 2 received
xl2tpd[3173]: Terminating pppd: sending TERM signal to pid 3594
xl2tpd[3173]: Connection 12670 closed to 113.98.195.201, port 1701 (Server closing)
~ # 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

2)连接命令:

~ # echo "c lroute" > /var/run/xl2tpd/l2tp-control
  • 1

3)配置文件:


~ # cat /tmp/xl2tpd/options.l2tpd.lac 
ipcp-accept-local
ipcp-accept-remote
refuse-eap
noauth
mtu 1410
mru 1410
debug
name test
password 11223344
lcp-echo-interval 0 
lcp-echo-failure 0
~ # 
~ # 
~ # 
~ # cat /tmp/xl2tpd/xl2tpd.conf 
[lac lroute]
lns = 113.98.195.201
pppoptfile = /tmp/xl2tpd/options.l2tpd.lac
redial = yes
redial timeout = 15
~ # 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

5. 解决方法

  • L2TP连接自己在linux搭建的服务器或者TP-link的企业路由器,都是可以成功。但是连接H3C的一个服务器时,出现拨号失败的问题。详细记录如下:
sean@sean:~/work/$ vi apps/ppp-2.4.7/pppd/ipcp.c

/*                                                                                                                                                                                                           
 * ip_check_options - check that any IP-related options are OK,
 * and assign appropriate defaults.
 */
static void 
ip_check_options()
{
    struct hostent *hp; 
    u_int32_t local;
    ipcp_options *wo = &ipcp_wantoptions[0];

    /*   
     * Default our local IP address based on our hostname.
     * If local IP address already given, don't bother.
     */
    if (wo->ouraddr == 0 && !disable_defaultip) {
    /*   
     * Look up our hostname (possibly with domain name appended)
     * and take the first IP address as our local IP address.
     * If there isn't an IP address for our hostname, too bad.
     */
    wo->accept_local = 1;   /* don't insist on this default value */
    if ((hp = gethostbyname(hostname)) != NULL) {
        local = *(u_int32_t *)hp->h_addr;
        if (local != 0 && !bad_ip_adrs(local))
        wo->ouraddr = local;
    }    
    }    
    ask_for_local = wo->ouraddr != 0 || !disable_defaultip;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 在此函数中,对hostname做了判断。但是如果ppp的配置文件中加入 “noipdefault”这个参数,就不会进入判断。进而解决问题。即配置文件改为(options.l2tpd.lac文件中增加noipdefault参数)
~ # cat /tmp/xl2tpd/options.l2tpd.lac 
ipcp-accept-local
ipcp-accept-remote
:
refuse-eap
noccp
noauth
mtu 1400
mru 1400
name tozed
password 33445588
lcp-echo-interval 20
lcp-echo-failure 3
ifname l2tp
usepeerdns
noipdefault
~ # 
~ # cat /tmp/xl2tpd/xl2tpd.conf 
[lac lroute]
lns = 113.98.195.201
pppoptfile = /tmp/xl2tpd/options.l2tpd.lac
redial = yes
redial timeout = 15
~ # 

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25

调试信息如下:

~ # xl2tpd -c /tmp/xl2tpd/xl2tpd.conf -D
xl2tpd[31309]: Not looking for kernel SAref support.
xl2tpd[31309]: Using l2tp kernel support.
xl2tpd[31309]: xl2tpd version xl2tpd-1.3.12 started on (TOZED-P53) PID:31309
xl2tpd[31309]: Written by Mark Spencer, Copyright (C) 1998, Adtran, Inc.
xl2tpd[31309]: Forked by Scott Balmos and David Stipp, (C) 2001
xl2tpd[31309]: Inherited by Jeff McAdams, (C) 2002
xl2tpd[31309]: Forked again by Xelerance (www.xelerance.com) (C) 2006-2016
xl2tpd[31309]: Listening on IP address 0.0.0.0, port 1701
xl2tpd[31309]: Connecting to host 113.98.195.201, port 1701
xl2tpd[31309]: Connection established to 113.98.195.201, 1701.  Local: 52610, Remote: 625 (ref=0/0).
xl2tpd[31309]: Calling on tunnel 52610
xl2tpd[31309]: Call established with 113.98.195.201, Local: 39099, Remote: 6548, Serial: 1 (ref=0/0)
xl2tpd[31309]: start_pppd: I'm running: 
xl2tpd[31309]: "/usr/sbin/pppd" 
xl2tpd[31309]: "plugin" 
xl2tpd[31309]: "pppol2tp.so" 
xl2tpd[31309]: "pppol2tp" 
xl2tpd[31309]: "7" 
xl2tpd[31309]: "passive" 
xl2tpd[31309]: "nodetach" 
xl2tpd[31309]: ":" 
xl2tpd[31309]: "file" 
xl2tpd[31309]: "/tmp/xl2tpd/options.l2tpd.lac" 



~ # 
~ # echo "c lroute" > /tmp/xl2tpd/l2tp-control 
~ # ifconfig l2tp
l2tp      Link encap:Point-to-Point Protocol  
          inet addr:172.1.1.100  P-t-P:172.1.1.199  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1400  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3 
          RX bytes:46 (46.0 B)  TX bytes:52 (52.0 B)

~ # 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/188894
推荐阅读
相关标签
  

闽ICP备14008679号