Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!rsc by RouterOS
- # RouterOS script: createHostfile
- # Copyright (c) 2022 Uco Mesdag <uco@mesd.ag>
- :global fileContent "";
- :foreach dnsEntry in=[ /ip/dns/static/find ] do={
- :local ip [ /ip/dns/static/get $dnsEntry address ];
- :local hostname [ /ip/dns/static/get $dnsEntry name ];
- :local comment [ /ip/dns/static/get $dnsEntry comment ];
- # Only get record for static ip addresses (no #DHCP)
- :if ( [ :len $comment ] = 0 ) do={
- :if ( [ :len $hostname ] != 0 ) do={
- :set fileContent ($fileContent . $ip . " " . $hostname . "\r\n");
- };
- };
- };
- :put $fileContent;
- /file print file=hostsfile;
- /file set hostsfile.txt contents="$fileContent";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement