# jun/22/2022 19:06:49 by RouterOS 7.2.1
# software id = *******
#
/interface bridge
add igmp-snooping=yes name=bridge-iptv
/interface ethernet
set [ find default-name=ether1 ] advertise=\
10M-half,10M-full,100M-half,100M-full,1000M-full disable-running-check=no \
speed=1Gbps
set [ find default-name=ether2 ] advertise=\
10M-half,10M-full,100M-half,100M-full,1000M-full disable-running-check=no \
speed=1Gbps
set [ find default-name=ether3 ] advertise=\
10M-half,10M-full,100M-half,100M-full,1000M-full disable-running-check=no \
speed=1Gbps
set [ find default-name=ether4 ] advertise=\
10M-half,10M-full,100M-half,100M-full,1000M-full disable-running-check=no \
speed=1Gbps
set [ find default-name=ether5 ] advertise=\
10M-half,10M-full,100M-half,100M-full,1000M-full disable-running-check=no \
speed=1Gbps
/interface wireless
set [ find default-name=wlan1 ] band=5ghz-a/n channel-width=20/40mhz-Ce \
country=spain frequency=auto mode=ap-bridge name=Wifi ssid=***********
/interface eoip
add !keepalive mac-address=*********** mtu=1500 name=eoip-iptv \
remote-address=*********** tunnel-id=0
/interface wireguard
add disabled=yes listen-port=36146 mtu=1420 name=wg-sts-iptv
/interface vlan
add interface=ether1 name=Internet vlan-id=6
add interface=ether1 name=TV vlan-id=2
add interface=ether1 name=Telefono vlan-id=3
/interface pppoe-client
add add-default-route=yes allow=pap,chap disabled=no interface=Internet \
keepalive-timeout=60 max-mru=1492 max-mtu=1492 name=pppoe-out1 \
use-peer-dns=yes user=adslppp@telefonicanetpa
/interface list
add comment="Vlan2 (Iptv) & Vlan3 (Voip)" name=Vlan2&3
add name=LAN
add name=WAN
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip dhcp-server option
add code=240 name=option_para_deco value=\
"':::::239.0.2.10:22222:v6.0:239.0.2.30:22222'"
/ip pool
add name=pool-iptv-descos ranges=192.168.77.201-192.168.77.206
add name=pool-iptv-hosts ranges=192.168.77.50-192.168.77.199
/ip dhcp-server
add address-pool=pool-iptv-hosts interface=bridge-iptv
/routing rip instance
add afi=ipv4 disabled=no name=rip
/interface bridge port
add bridge=bridge-iptv interface=ether5
add bridge=bridge-iptv interface=ether2
add bridge=bridge-iptv interface=ether3
add bridge=bridge-iptv interface=ether4
add bridge=bridge-iptv interface=eoip-iptv
/interface list member
add interface=pppoe-out1 list=WAN
add interface=TV list=Vlan2&3
add interface=Telefono list=Vlan2&3
add interface=bridge-iptv list=LAN
/interface wireguard peers
add allowed-address=0.0.0.0/0 disabled=yes endpoint-address=\
*********** endpoint-port=54321 interface=wg-sts-iptv \
public-key="***********"
/ip address
add address=***********/9 comment=\
"My Telefonica's IPTV address, from NOLTARI" interface=TV network=\
10.128.0.0
add address=192.168.77.1/24 comment="IPTV subnet" interface=bridge-iptv \
network=192.168.77.0
add address=172.17.0.2/30 interface=wg-sts-iptv network=172.17.0.0
/ip cloud
set update-time=no
/ip dhcp-client
add add-default-route=no interface=Telefono use-peer-ntp=no
/ip dhcp-server lease
add address=192.168.77.206 client-id="48:55:4d:41:58:5f:50:54:54:31:30:30:30:5\
f:45:53:5f:45:43:43:33:30:32:37:30:35:46:33:45" mac-address=\
*********** server=dhcp-server-iptv
add address=192.168.77.184 client-id=1:92:1:ed:b4:49:88 mac-address=\
*********** server=dhcp-server-iptv
/ip dhcp-server network
add address=192.168.77.0/24 comment="IPTV subnet for hosts" gateway=\
192.168.77.1 netmask=24
add address=192.168.77.200/29 comment="IPTV subnet for descos" dhcp-option=\
option_para_deco dns-server=172.26.23.3 gateway=192.168.77.1 netmask=24
/ip dhcp-server vendor-class-id
add address-pool=pool-iptv-descos name="Movistar Descos" server=\
dhcp-server-iptv vid="[IAL]"
/ip firewall filter
add action=accept chain=input comment="Accept vlan2 Iptv IGMP packets" \
in-interface=TV protocol=igmp
add action=accept chain=input comment=\
"Accept vlan2 & 3 (Iptv & Voip) multicast & broadcast traffic" \
dst-address-type=!unicast in-interface-list=Vlan2&3
add action=drop chain=forward comment=\
"Drop all new unicast traffic from vlan3 & 2 (Voip & Iptv) not DSTNATed" \
connection-nat-state=!dstnat connection-state=new dst-address-type=\
unicast in-interface-list=Vlan2&3
add action=accept chain=input protocol=gre
/ip firewall mangle
add action=set-priority chain=postrouting comment="Prioritise Voip packets" \
new-priority=5 out-interface=Telefono passthrough=yes
add action=set-priority chain=postrouting comment="Prioritise Iptv packets" \
new-priority=4 out-interface=TV passthrough=yes
# pppoe-out1 not ready
add action=set-priority chain=postrouting new-priority=1 out-interface=\
pppoe-out1
add action=add-src-to-address-list address-list=vod-receiver \
address-list-timeout=1m chain=postrouting comment="RTSP - VOD Movistar" \
connection-state=new dst-port=554 out-interface=TV protocol=tcp
/ip firewall nat
add action=masquerade chain=srcnat comment=\
"masq. vlan2 & vlan3 (Iptv & Voip)" out-interface-list=Vlan2&3
add action=masquerade chain=srcnat comment="masq. IPTV hosts" src-address=\
192.168.77.0/24
add action=dst-nat chain=dstnat comment="VOD Script" dst-address-type=local \
in-interface=TV to-addresses=192.168.77.205
add action=dst-nat chain=dstnat comment="VOD Script" dst-address-type=local \
in-interface=TV to-addresses=192.168.77.204
/ip service
set telnet disabled=yes
set ftp disabled=yes
set www disabled=yes
set ssh disabled=yes
/routing igmp-proxy
set query-interval=30s quick-leave=yes
/routing igmp-proxy interface
add alternative-subnets=0.0.0.0/0 interface=TV upstream=yes
add interface=bridge-iptv
/routing rip interface-template
add disabled=no instance=rip interfaces=Vlan2&3 mode=passive \
source-addresses=""
/system clock
set time-zone-name=Europe/Madrid
/system hardware
set allow-x86-64=yes
/system scheduler
add interval=6s name=vod on-event=vod policy=read,write start-time=startup
/system script
add dont-require-permissions=no name=vod owner=admin policy=read,write \
source=":local iplist [:len [/ip firewall address-list find list=\"vod-rec\
eiver\"]]\
\n:local rules [:len [/ip firewall nat find where comment=\"VOD Script\"]]\
\n#:log info \"VODScript: IPs in list are \$iplist !\"\
\n#:log info \"VODScript: Rules are \$rules !\"\
\n:if (\$iplist = 0 and \$rules > 0) do={\
\n\t#/ip firewall nat remove [find comment=\"VOD Script\"];\
\n\t#:log info \"VODScript: Rule removed !\"\
\n} else {\
\n\t:local ipadressnew [/ip firewall address-list get [:pick [/ip firewall\
\_address-list find list=\"vod-receiver\"] (\$iplist-1)] address]\
\n\t:local ipadressold \"None\"\
\n\t#:log info \"VODScript: IP address new is \$ipadressnew !\"\
\n\t:if (\$iplist > 0 ) do {\
\n\t\tif (\$rules > 0 ) do {\
\n\t\t\t:set ipadressold [/ip firewall nat get [find comment=\"VOD Script\
\"] to-addresses] \
\n\t\t\t#:log info \"VODScript: IP address old is \$ipadressold !\"\
\n\t\t}\
\n\t\t:if (\$ipadressnew != \$ipadressold) do={\
\n\t\t\tif (\$rules > 0 ) do {\
\n\t\t\t\t/ip firewall nat remove [find comment=\"VOD Script\"];\
\n\t\t\t}\
\n\t\t\t/ip firewall nat add action=dst-nat chain=dstnat comment=\"VOD Scr\
ipt\" dst-address-type=local in-interface=iptv-vlan2 to-addresses=\$ipadre\
ssnew\
\n\t\t\t:log info \"VODScript: IP address changed from \$ipadressold to \$\
ipadressnew !\"\
\n\t\t}\
\n\t}\
\n}"