Last active 1 month ago

Update Samba4 IP with samba-tool

updateip.sh Raw
1#!/bin/bash
2
3DOMAIN=$1
4OLDIP=$2
5NEWIP=$3
6SERVERNAME=$4
7
8echo "Adding new IP to domain"
9samba-tool dns add localhost $DOMAIN $SERVERNAME.$DOMAIN A $NEWIP
10samba-tool dns add localhost $DOMAIN $DOMAIN A $NEWIP
11samba-tool dns add localhost _msdcs.$DOMAIN gc A $NEWIP
12samba-tool dns add localhost $DOMAIN DomainDnsZones.$DOMAIN A $NEWIP
13samba-tool dns add localhost $DOMAIN ForestDnsZones.$DOMAIN A $NEWIP
14
15echo "Removing old IP from domain"
16samba-tool dns delete localhost _msdcs.$DOMAIN gc A $OLDIP
17samba-tool dns delete localhost $DOMAIN $SERVERNAME.$DOMAIN A $OLDIP
18samba-tool dns delete localhost $DOMAIN $DOMAIN A $OLDIP
19samba-tool dns delete localhost $DOMAIN DomainDnsZones.$DOMAIN A $OLDIP
20samba-tool dns delete localhost $DOMAIN ForestDnsZones.$DOMAIN A $OLDIP
21