公司的一个ros需求创建10个ssid,走10根pptp线路,同时更换mac
红色的部分,是你要创建10个ssid的编号。从1到10一共10个。顺序不能变。
foreach y in={[/interface wireless find where interface-type=virtual]} do={/interface wireless remove $y};
foreach y in={[/ip address find address ~ "172.16"]} do={/ip address remove $y};
foreach y in={[/ip pool find ranges ~ "172.16"]} do={/ip pool remove $y};
foreach y in={[/ip dhcp-server find name ~ "A"]} do={/ip dhcp-server remove $y};
foreach y in={[/ip dhcp-server network find address ~ "172.16"]} do={/ip dhcp-server network remove $y};
foreach y in={[/certificate scep-server otp find]} do={/certificate scep-server otp remove $y};
:global oo [/ip firewall mangle find];
:global cc [/ip firewall nat find];
:global jj 0;
:for i from=21 to=30 do={
:global mac1 [/certificate scep-server otp generate minutes-valid=1 as-value] ;
:global mac2 ($mac1->"password");
:global mac [:pick $mac2 0 12];
:global ssid ("A". $i);
:global wlname ("A". $i);
:log error ("正在创建ssid" . $ssid);
/interface wireless add master-interface=wlan2 ssid=$ssid mac-address=$mac name=$wlname security-profile="profile1" default-forwarding=no disabled=no wps-mode=disabled;
/ip address add address=("172.168." . $i . ".1/24" ) interface=$wlname;
/ip pool add ranges=("172.168." .$i .".100-172.168.". $i.".200") name=$wlname;
/ip dhcp-server add name=$wlname address-pool=$wlname interface=$wlname disa=no;
/ip dhcp-server network add address=("172.168.". $i .".0/24") dns-server=114.114.114.114 gateway=("172.168." .$i. ".1") netmask=24;
/ip firewall mangle set ($oo->$jj) src-address=("172.168.".$i.".0/24");
/ip firewall nat set ($cc->$jj) src-address=("172.168.".$i.".0/24");
set $jj ($jj+1);
}
来源:oschina
链接:https://my.oschina.net/u/4397452/blog/4293096