Community discussions

MikroTik App
 
bshierscerento
just joined
Topic Author
Posts: 1
Joined: Sat Aug 21, 2010 4:47 am

Running a script on PPP session up

Fri Jan 25, 2019 1:02 am

I have a number of PPPoE customers that I need to create a firewall rule like this one when their session comes up:

20 chain=forward action=change-mss new-mss=clamp-to-pmtu passthrough=no
tcp-flags=syn protocol=tcp in-interface=<pppoe-username> tcp-mss=1453-65535
log=no log-prefix=""

21 chain=forward action=change-mss new-mss=clamp-to-pmtu passthrough=no
tcp-flags=syn protocol=tcp out-interface=<pppoe-username>
tcp-mss=1453-65535 log=no log-prefix=""

I want to use the On Up script section in my PPP server. How would I create these rules as users authenticate?
 
User avatar
inteq
Member
Member
Posts: 429
Joined: Wed Feb 25, 2015 8:15 pm
Location: Romania

Re: Running a script on PPP session up

Thu Feb 14, 2019 8:41 pm

Create a profile for each user.
Run the script via the profile on up/down
Or maybe I did not understood your question?
 
ianngrh
newbie
Posts: 26
Joined: Thu Aug 30, 2018 6:53 am

Re: Running a script on PPP session up

Mon Feb 18, 2019 6:26 am

As mentioned by @inteq you can set on-up script on ppp profile. But no need to create each profile for each user just to create new change mss script.
Just copy the script below and paste on the ppp profile default / default-encryption script if currently you only use default / default-encryption profile.

On Up Script :
/ip firewall mangle add chain=forward action=change-mss new-mss=clamp-to-pmtu passthrough=no tcp-flags=syn protocol=tcp in-interface=$interface tcp-mss=1453-65535 log=no log-prefix="" comment=$user;

/ip firewall mangle add chain=forward action=change-mss new-mss=clamp-to-pmtu passthrough=no tcp-flags=syn protocol=tcp out-interface=$interface tcp-mss=1453-65535 log=no log-prefix="" comment=$user;

on Down Script :
/ip firewall mangle remove [find comment=$user];

The script above will create a new firewall on new ppp interface and use the username as comment when the ppp user logged in. When the user logged out, the mangle rule will be deleted.