1

I have a FreeBSD server that's connected to WAN using PPPoE. Iva esuccessfully set ip the L2TP and PPTP VPN ontop of this PPPoE WAN connection. The problem is that L2TP needs to call 'set lt2p self ` clause to start listening to the udp/1701 port, so when the WAN PPPoE session is reestablished, I need to dynamically set up the L2TP config part. I'm using an expect script to do this, it connects to the mpd5 network console and loads the config part, and does it like this:

set timeout 2
spawn telnet localhost 5005

expect -re "Username: " {
    send myc00ll0g1n\r
    exp_continue -continue_timer
}
expect -re "Password: " {
    send myc00lpa$$\r
    exp_continue -continue_timer
}

# destroying the knob
send "destroy link l2tplink\r"
expect ".+"
send "destroy bundle l2tpbundle\r"
expect ".+"

# loading the full knob:
send "create bundle template l2tpbundle\r"
expect ".+"
send "set iface idle 1800\r"
expect ".+"
send "set iface enable tcpmssfix\r"
expect ".+"
send "set iface group vpn\r"
expect ".+"
expect ".+"
send "set ipcp yes vjcomp\r"
expect ".+"
send "set ipcp ranges 192.168.58.1/32 ippool vpn-pool\r"
expect ".+"
send "set ipcp dns 192.168.57.254\r"
expect ".+"
send "set bundle enable compression\r"
expect ".+"
send "create link template l2tplink l2tp\r"
expect ".+"
send "set link action bundle l2tpbundle\r"
expect ".+"
send "set link enable multilink\r"
expect ".+"
send "set link yes acfcomp protocomp\r"
expect ".+"
send "set link no pap chap eap chap-md5 chap-msv1 chap-msv2\r"
expect ".+"
send "set link enable chap\r"
expect ".+"
send "set link enable pap\r"
expect ".+"
send "set link enable chap-md5\r"
expect ".+"
send "set link enable chap-msv1\r"
expect ".+"
send "set link enable chap-msv2\r"
expect ".+"
send "set link enable eap\r"
expect ".+"
send "set eap no md5 radius-proxy\r"
expect ".+"
send "set eap enable eap\r"
expect ".+"
send "set eap enable radius-proxy\r"
expect ".+"
send "set link keep-alive 10 60\r"
expect ".+"
send "set link mtu 1360\r"
expect ".+"
send "set link enable incoming\r"
expect ".+"
send "set l2tp self 384.656.768.272\r"
expect ".+"
send "set link max-children 50\r"
expect ".+"
send "set radius server 127.0.0.1 myc00lradiuspa$$\r"
expect ".+"
send "set radius retries 3\r"
expect ".+"
send "set radius timeout 3\r"
expect ".+"
send "set radius me 127.0.0.1\r"
expect ".+"
send "set auth acct-update 300\r"
expect ".+"
send "set auth enable radius-auth\r"
expect ".+"

It's fully working when I invoke it interactively via ssh. So I added it into the set iface up-script <expect wrapper> and the expect wrapper is calling it like expect -f myscript.exp. But when it does that on PPPoE connection reestablishing, I receive the following bunch of errors in the mpd.log:

Mar 21 17:42:23 ronin mpd[37412]: [wan] IFACE: Up event
Mar 21 17:42:23 ronin mpd[37412]: CONSOLE: Connect
Mar 21 17:42:23 ronin mpd[37412]: CONSOLE: Allocated new console session 0x802000010 from 127.0.0.1
Mar 21 17:42:23 ronin mpd[37412]: CONSOLE: Failed login attempt from 127.0.0.1
Mar 21 17:42:23 ronin syslogd: last message repeated 34 times
Mar 21 17:42:23 ronin mpd[37412]: CONSOLE: Error while reading: Connection reset by peer

And this is definitely my expect script (because it does send right about 34 lines of commands). Why ? Why does it work when I invoke it by hand and when mpd5 invokes it - it does not ? Okay, I understand that when I invoke it it has a controlling terminal, and when mpd5 invokes it it does not, but does it matter ? How do I solve this ? Or is the root of the problem something else ?

  • what about raising the timeout or add a sleep? maybe mpd5 needs some time? please add an debug output to your script like: ``` log_file /tmp/mylog.txt ``` – Bastian Bittorf Mar 31 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.