Community discussions

MikroTik App
 
User1992
just joined
Topic Author
Posts: 9
Joined: Thu Aug 12, 2021 11:28 am

Router disappears after running script for system reset-configuration

Wed Aug 18, 2021 11:45 am

Hi, I'm trying to run the command:
system reset-configuration keep-users=yes no-defaults=yes run-after-reset=script.rsc
When I run this the router should be renamed to 'ChangeName' and the IP address changed to 192.168.100.1. However the router simply disappears and can't be found on the network, I have to hard reset the router back to default 192.168.88.1 in order to use it again. Any idea why this is happening? Below is the script I'm trying to execute during the reset.
:delay 20s
# jan/02/1970 00:09:21 by RouterOS 6.45.9
# software id = X29E-M5U5
#
# model = RB962UiGS-5HacT2HnT
# serial number = CC4F0C5263CE
/interface bridge
add admin-mac=48:8F:5A:C6:8D:21 auto-mac=no comment=defconf name=bridge
/interface wireless
set [ find default-name=wlan1 ] band=2ghz-b/g/n channel-width=20/40mhz-XX \
    disabled=no distance=indoors frequency=auto installation=indoor mode=\
    ap-bridge ssid=ChangeName wireless-protocol=802.11
set [ find default-name=wlan2 ] band=5ghz-a/n/ac channel-width=\
    20/40/80mhz-XXXX distance=indoors frequency=auto installation=indoor \
    mode=station-pseudobridge ssid=ChangeNameB wireless-protocol=802.11
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/interface wireless security-profiles
set [ find default=yes ] authentication-types=wpa-psk,wpa2-psk mode=\
    dynamic-keys supplicant-identity=MikroTik wpa-pre-shared-key=Password \
    wpa2-pre-shared-key=Password
/ip hotspot profile
set [ find default=yes ] html-directory=flash/hotspot
/ip pool
add name=dhcp ranges=192.168.100.150-192.168.100.160
/ip dhcp-server
add address-pool=dhcp disabled=no interface=bridge name=defconf
/interface bridge port
add bridge=bridge comment=defconf interface=ether2
add bridge=bridge comment=defconf interface=ether3
add bridge=bridge comment=defconf interface=ether4
add bridge=bridge comment=defconf interface=ether5
add bridge=bridge comment=defconf interface=sfp1
add bridge=bridge comment=defconf interface=wlan1
add bridge=bridge comment=defconf interface=wlan2
add bridge=bridge interface=ether1
/ip neighbor discovery-settings
set discover-interface-list=LAN
/interface list member
add interface=wlan2 list=WAN
add interface=ether1 list=LAN
add interface=ether2 list=LAN
add interface=ether3 list=LAN
add interface=ether4 list=LAN
add interface=ether5 list=LAN
add interface=sfp1 list=LAN
add interface=wlan1 list=LAN
/ip address
add address=192.168.100.1/24 comment=defconf interface=ether1 network=\
    192.168.100.0
/ip dhcp-client
# DHCP client can not run on slave interface!
add comment=defconf dhcp-options=hostname,clientid disabled=no interface=\
    ether1
/ip dhcp-server network
add address=192.168.100.0/24 comment=defconf gateway=192.168.100.1 netmask=24
/ip dns
set allow-remote-requests=yes
/ip dns static
add address=192.168.100.1 comment=defconf name=router.lan
/ip firewall filter
add action=accept chain=input comment=\
    "defconf: accept established,related,untracked" connection-state=\
    established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=\
    invalid
add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
add action=accept chain=input comment=\
    "defconf: accept to local loopback (for CAPsMAN)" dst-address=127.0.0.1
add action=drop chain=input comment="defconf: drop all not coming from LAN" \
    in-interface-list=!LAN
add action=accept chain=forward comment="defconf: accept in ipsec policy" \
    ipsec-policy=in,ipsec
add action=accept chain=forward comment="defconf: accept out ipsec policy" \
    ipsec-policy=out,ipsec
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" \
    connection-state=established,related
add action=accept chain=forward comment=\
    "defconf: accept established,related, untracked" connection-state=\
    established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" \
    connection-state=invalid
add action=drop chain=forward comment=\
    "defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat \
    connection-state=new in-interface-list=WAN
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" \
    ipsec-policy=out,none out-interface-list=WAN
/tool mac-server
set allowed-interface-list=LAN
/tool mac-server mac-winbox
set allowed-interface-list=LAN
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Router disappears after running script for system reset-configuration

Wed Aug 18, 2021 11:52 am

Have you read your script at least once?
/ip dhcp-client
# DHCP client can not run on slave interface!
add comment=defconf dhcp-options=hostname,clientid disabled=no interface=\
    ether1

*****************************

on script change:
increase delay to 30s

from
add admin-mac=48:8F:5A:C6:8D:21 auto-mac=no comment=defconf name=bridge
to
add admin-mac=[/int ethernet get ether2 mac-address] auto-mac=no comment=defconf name=bridge protocol=none

from
set [ find default-name=wlan1 ] band=2ghz-b/g/n
to
set [ find default-name=wlan1 ] band=2ghz-g/n


from
set [ find default=yes ] authentication-types=wpa-psk,wpa2-psk mode=\
    dynamic-keys supplicant-identity=MikroTik wpa-pre-shared-key=Password \
to
set [ find default=yes ] authentication-types=wpa2-psk mode=\
    dynamic-keys supplicant-identity=MikroTik \

remove this line:
add bridge=bridge comment=defconf interface=wlan2

from
add address=192.168.100.1/24 comment=defconf interface=ether1 network=\
to
add address=192.168.100.1/24 comment=defconf interface=bridge network=\

from
# DHCP client can not run on slave interface!
add comment=defconf dhcp-options=hostname,clientid disabled=no interface=\
    ether1
to
add comment=defconf dhcp-options=hostname,clientid disabled=no interface=wlan2
 
User1992
just joined
Topic Author
Posts: 9
Joined: Thu Aug 12, 2021 11:28 am

Re: Router disappears after running script for system reset-configuration

Wed Aug 18, 2021 12:12 pm

Have you read your script at least once?
/ip dhcp-client
# DHCP client can not run on slave interface!
add comment=defconf dhcp-options=hostname,clientid disabled=no interface=\
    ether1

And why you put
ether1 on bridge,
wlan2 on WAN without remove it from bridge,
and other oddities,
breaking all the other elements?
I don't know much about networks, that's why I'm asking here. So far I just set the name, IP address on local network, passwords, DHCP server range in local network, set internet to auto in quickset Home AP Dual and then afterwards bridge ports in CPE. This works for what I'm doing, allowing the router to see devices connected to it, so all I've done is create a script after making those changes in quickset.
 
User1992
just joined
Topic Author
Posts: 9
Joined: Thu Aug 12, 2021 11:28 am

Re: Router disappears after running script for system reset-configuration

Wed Aug 18, 2021 1:54 pm

Have you read your script at least once?
/ip dhcp-client
# DHCP client can not run on slave interface!
add comment=defconf dhcp-options=hostname,clientid disabled=no interface=\
    ether1

*****************************

on script change:
increase delay to 30s

from
add admin-mac=48:8F:5A:C6:8D:21 auto-mac=no comment=defconf name=bridge
to
add admin-mac=[/int ethernet get ether2 mac-address] auto-mac=no comment=defconf name=bridge protocol=none

from
set [ find default-name=wlan1 ] band=2ghz-b/g/n
to
set [ find default-name=wlan1 ] band=2ghz-g/n


from
set [ find default=yes ] authentication-types=wpa-psk,wpa2-psk mode=\
    dynamic-keys supplicant-identity=MikroTik wpa-pre-shared-key=Password \
to
set [ find default=yes ] authentication-types=wpa2-psk mode=\
    dynamic-keys supplicant-identity=MikroTik \

remove this line:
add bridge=bridge comment=defconf interface=wlan2

from
add address=192.168.100.1/24 comment=defconf interface=ether1 network=\
to
add address=192.168.100.1/24 comment=defconf interface=bridge network=\

from
# DHCP client can not run on slave interface!
add comment=defconf dhcp-options=hostname,clientid disabled=no interface=\
    ether1
to
add comment=defconf dhcp-options=hostname,clientid disabled=no interface=wlan2
So I tried those edits and it still doesn't work. I then tried creating a new script where literally all I did was change the name of the router and nothing else. Bear in mind that the router is visible and I can connect to it just fine. However as soon as I run that script where all I did was change the name, the router disappears. It works just fine if I do it in quickset instead of from a script. It looks like reset-configuration just doesn't work, I was hoping to automate the setup of routers but it doesn't look like it's possible.
 
biomesh
Long time Member
Long time Member
Posts: 561
Joined: Fri Feb 10, 2012 8:25 pm

Re: Router disappears after running script for system reset-configuration

Wed Aug 18, 2021 2:24 pm

The process works, you just have at least one issue in your script. I see you have your lan IP address assigned to ether1, not the bridge interface. It looks like all interfaces are assigned to the bridge, which won't work if you actually want this to work correctly (as a router). If you were just changing the device name, you would just run one command to change the identity. It looks like you are changing the full config. If you want access to the device while configuring but don't want to lose access, I would suggest getting a woobm to plug into the USB port for console access.
 
User1992
just joined
Topic Author
Posts: 9
Joined: Thu Aug 12, 2021 11:28 am

Re: Router disappears after running script for system reset-configuration

Wed Aug 18, 2021 4:05 pm

The process works, you just have at least one issue in your script. I see you have your lan IP address assigned to ether1, not the bridge interface. It looks like all interfaces are assigned to the bridge, which won't work if you actually want this to work correctly (as a router). If you were just changing the device name, you would just run one command to change the identity. It looks like you are changing the full config. If you want access to the device while configuring but don't want to lose access, I would suggest getting a woobm to plug into the USB port for console access.
I'm basically trying to create a python program that will load a script onto a router and then just run that whole script after resetting it with all the necessary edits I've made from a template router. From a paramiko python script I can issue single commands to the terminal but its a bit finnicky, trying to change names, passwords, IP addresses and bridging LAN ports gets messy.

I'm working on a product with the Mikrotik router being connected to raspberry pi's and cameras. I connect to the router through winbox on its default 192.168.88.1 and set the IP address and DHCP server range on local then I bridge the LAN ports in order to see the pi's and the cameras for me to connect to them for configuration. So I think the router is more acting as a bridge than a router? I'm not a network engineer so just learning all of this stuff. I just don't get how there's errors in the script but it somehow works when I just use quick setup, surely if that works and I then just export that as a script it should just work fine? Confused.
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11381
Joined: Thu Mar 03, 2016 10:23 pm

Re: Router disappears after running script for system reset-configuration

Wed Aug 18, 2021 4:29 pm

When you reset your router and start off with QuickSet, at that moment router is not without any config. It has quite some config applied already and you only apply some minor changes via GUI. Which is far from the state you're getting into by issuing /system reset-configuration keep-users=yes no-defaults=yes ... If you want to see, what is actual default config, run command /system default-configuration print (make sure your terminal windows is really wide ... long config lines get truncated) ... you'll see script which gets executed if you run /system reset-configuration keep-users=yes no-defaults=no.
 
sid5632
Long time Member
Long time Member
Posts: 552
Joined: Fri Feb 17, 2017 6:05 pm

Re: Router disappears after running script for system reset-configuration

Wed Aug 18, 2021 6:31 pm

Aside from the IP address on ether1 thing already mentioned, why are you putting wlan2 into the WAN interface list and then bridging it with all the interfaces you've put in the LAN interface list?
Have you any idea what you are actually doing, or are you just guessing?
I always assumed Beginner Basics was related to MikroTik kit, not about networking in general.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Router disappears after running script for system reset-configuration

Wed Aug 18, 2021 6:51 pm

you are rewriting things already reported...
viewtopic.php?f=13&t=177670#p873306
 
User1992
just joined
Topic Author
Posts: 9
Joined: Thu Aug 12, 2021 11:28 am

Re: Router disappears after running script for system reset-configuration

Thu Aug 19, 2021 12:09 pm

Aside from the IP address on ether1 thing already mentioned, why are you putting wlan2 into the WAN interface list and then bridging it with all the interfaces you've put in the LAN interface list?
Have you any idea what you are actually doing, or are you just guessing?
I always assumed Beginner Basics was related to MikroTik kit, not about networking in general.
No, I don't know what I'm doing, why do you think I'm on a Mikrotik router forum in a section called beginner basics asking basic questions about routers and mikrotik kit? I make some small edits to a pre-existing script through the quickset gui and that works for that small part of my job of bridging devices connected to the router. All I wanted to do was automate the execution of those commands for other routers in a python script. I did not make the rest of the script configuration, someone else did, I was simply told by this forum to make the small changes I wanted and then export as a script and run that after reset. Obviously that didn't work out.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Router disappears after running script for system reset-configuration

Thu Aug 19, 2021 2:33 pm

Without offense, you don't even understand the warning inside the script (just read),
# DHCP client can not run on slave interface!

Modifing manually a script and after that running a (valid) script after reset is not a "Beginner Basics".

First learn to tie your shoes, then you can run.

Who is online

Users browsing this forum: sybadi and 38 guests