Community discussions

MikroTik App
 
User avatar
goscickiw
newbie
Topic Author
Posts: 28
Joined: Fri Feb 17, 2023 8:56 am
Location: Poland

Scripts for adding DHCP and PPPoE public IPs to address list. Is there a version for LTE?

Wed Dec 20, 2023 7:17 pm

I'm using these scripts to add a public IP and ISP gateway addresses obtained from a DHCP or PPPoE client to an address list (on different routers). Is there a way to do the same thing on an LTE interface? I don't see any place for the script in Winbox settings for the LTE interface or the LTE APN profile.

Also, are these good, or should something be added/changed to avoid an issue?

Script for DHCP client - added in "Advanced" tab:
:if ($bound = 1) do={
	/ip firewall address-list {
		remove [find list="WAN-IP" address!=$"lease-address"];
		:if ([:len [find list=WAN-IP address=$"lease-address"]]=0) do={
			add list="WAN-IP" address=$"lease-address" comment="Public IP";
		}
		:if ([:len [find list=WAN-ISP address=$"server-address"]]=0) do={
			remove [find list="WAN-ISP" address!=$"gateway-address"];
			add list="WAN-ISP" address=$"server-address" comment="ISP's DHCP";
		}
		:if ([:len [find list=WAN-ISP address=$"gateway-address"]]=0) do={
			remove [find list="WAN-ISP" address!=$"server-address"];
			add list="WAN-ISP" address=$"gateway-address" comment="ISP's Gateway";
		}
	}
}

Script for PPPoE client - added in "Scripts" tab of PPP profile:
On up:
/ip firewall address-list add list=WAN-IP address=$"local-address";
/ip firewall address-list add list=WAN-ISP address=$"remote-address";
On down:
/ip firewall address-list remove [find where list="WAN-IP"];
/ip firewall address-list remove [find where list="WAN-ISP"];

Who is online

Users browsing this forum: No registered users and 6 guests