{"id":3001,"date":"2020-02-06T05:28:56","date_gmt":"2020-02-06T11:28:56","guid":{"rendered":"http:\/\/www.incredigeek.com\/home\/?p=3001"},"modified":"2020-02-06T05:31:44","modified_gmt":"2020-02-06T11:31:44","slug":"move-multiple-vlans-between-two-interfaces-mikrotik","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/move-multiple-vlans-between-two-interfaces-mikrotik\/","title":{"rendered":"Move multiple VLANs between two interfaces &#8211; Mikrotik"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Move VLANs with foreach<\/h2>\n\n\n\n<p>Move all the VLANs under ether7 to ether6.  Instead of an &#8220;=&#8221; sign, you can use a &#8220;~&#8221; to do a partial match.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">foreach i in=[\/interface vlan find where interface=\"ether7\"] do={interface vlan set interface=ether6-master-local  $i } <\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Move IP address to new port programmatically<\/h2>\n\n\n\n<p>Move ip address from ether6 to ether7.  Change 192.168.88.1\/24 to the address and the find command will find it regardless of the port and assign it to ether6 or whichever port is specified.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ip address set interface=ether6-master-local [find address=\"192.168.88.1\/24\"]<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Using Delay<\/h2>\n\n\n\n<p>You can add a delay before a command runs by specifying delay and then the time to wait.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">delay 60 <\/pre>\n\n\n\n<p>Use the ; to separate commands.  Example below, wait 5 seconds then print the ip addresses.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">delay 5 ; ip address print<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Putting it all together<\/h2>\n\n\n\n<p>The following command\/s will wait 60 seconds then move all the VLANs on ether7 to ether6 and then move the 192.168.88.1\/24 address to ether6.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">delay 60 ; foreach i in=[\/interface vlan find where interface=\"ether7\"] do={interface vlan set interface=ether6-master-local  $i } ; ip address set interface=ether6-master-local [find address=\"192.168.88.1\/24\"]<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Move VLANs with foreach Move all the VLANs under ether7 to ether6. Instead of an &#8220;=&#8221; sign, you can use a &#8220;~&#8221; to do a partial match. foreach i in=[\/interface vlan find where interface=&#8221;ether7&#8243;] do={interface vlan set interface=ether6-master-local $i } &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/move-multiple-vlans-between-two-interfaces-mikrotik\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[452],"tags":[893,892,431,301,388,173,405,875],"class_list":["post-3001","post","type-post","status-publish","format-standard","hentry","category-mikrotik","tag-delay","tag-foreach","tag-loop","tag-mikrotik","tag-routeros","tag-script","tag-scripting","tag-vlan"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/3001","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=3001"}],"version-history":[{"count":4,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/3001\/revisions"}],"predecessor-version":[{"id":3008,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/3001\/revisions\/3008"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=3001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=3001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=3001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}