Skip to content

Commit 561dad5

Browse files
refactor(setup ad): add use rfc2307 and forwarder dns
1 parent 558858e commit 561dad5

File tree

8 files changed

+18
-5
lines changed

8 files changed

+18
-5
lines changed

setup_debian-active-directory/1-install_samba_ad.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ systemctl restart networking
3636
# 3. Configure resolve file
3737
cat > /etc/resolv.conf << EOF
3838
search ${REALM}
39-
nameserver ${PRIMARY_DC_GATEWAY_IP}
39+
nameserver ${PRIMARY_DC_FORWARDER_DNS}
4040
EOF
4141

4242
# 4. Set hostname
@@ -78,7 +78,8 @@ rm -f /var/lib/samba/private/*.tdb
7878
echo "Provisioning Samba AD..."
7979
samba-tool domain provision --use-rfc2307 --realm="${REALM}" --domain="${DOMAIN}" \
8080
--server-role=dc --dns-backend=SAMBA_INTERNAL --adminpass="${ADMIN_PASSWORD}" \
81-
--option="interfaces=127.0.0.1 ${PRIMARY_DC_IP}" --option="bind interfaces only=yes"
81+
--option="interfaces=127.0.0.1 ${PRIMARY_DC_IP}" --option="bind interfaces only=yes" \
82+
--option="dns forwarder=${PRIMARY_DC_FORWARDER_DNS}"
8283

8384
# 11. Copy Kerberos configuration
8485
echo "Configuring Kerberos..."
@@ -97,7 +98,6 @@ iface ${PRIMARY_DC_INTERFACE} inet static
9798
address ${PRIMARY_DC_IP}
9899
netmask 255.255.255.0
99100
gateway ${PRIMARY_DC_GATEWAY_IP}
100-
dns-nameservers ${PRIMARY_DC_IP}
101101
EOF
102102
systemctl restart networking
103103

setup_debian-active-directory/2-join_additional_dc.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ echo "Joining domain as additional DC..."
8080
samba-tool domain join ${REALM} DC -U"administrator%${ADMIN_PASSWORD}" \
8181
--option="interfaces=127.0.0.1 ${SECONDARY_DC_IP}" \
8282
--option="bind interfaces only=yes" \
83+
--option="idmap_ldb:use rfc2307 = yes" \
84+
--option="dns forwarder=${SECONDARY_DC_FORWARDER_DNS}" \
8385
--dns-backend=SAMBA_INTERNAL
8486

8587
# 11. Copy Kerberos configuration

setup_debian-active-directory/2-join_additional_rodc.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ echo "Joining domain as additional DC..."
8080
samba-tool domain join ${REALM} RODC -U"administrator%${ADMIN_PASSWORD}" \
8181
--option="interfaces=127.0.0.1 ${SECONDARY_DC_IP}" \
8282
--option="bind interfaces only=yes" \
83+
--option="idmap_ldb:use rfc2307 = yes" \
84+
--option="dns forwarder=${SECONDARY_DC_FORWARDER_DNS}" \
8385
--dns-backend=SAMBA_INTERNAL
8486

8587
# 11. Copy Kerberos configuration

setup_debian-active-directory/env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ PRIMARY_DC_IP="10.10.20.220"
77
PRIMARY_DC_INTERFACE="enp1s0"
88
PRIMARY_DC_NETWORK="10.10.20.0/24"
99
PRIMARY_DC_GATEWAY_IP="10.10.20.1"
10+
PRIMARY_DC_FORWARDER_DNS="${PRIMARY_DC_GATEWAY_IP}"
1011
PRIMARY_DC_PTR_ADDRESS="20.10.10.in-addr.arpa"
1112

1213
# Secondary DC Configuration
@@ -15,6 +16,7 @@ SECONDARY_DC_IP="10.10.20.221"
1516
SECONDARY_DC_INTERFACE="enp1s0"
1617
SECONDARY_DC_NETWORK="10.10.20.0/24"
1718
SECONDARY_DC_GATEWAY_IP="10.10.20.1"
19+
SECONDARY_DC_FORWARDER_DNS="${SECONDARY_DC_GATEWAY_IP}"
1820
SECONDARY_DC_PTR_ADDRESS="20.10.10.in-addr.arpa"
1921

2022
# Domain Admin Password (change this!)

setup_ubuntu-active-directory/1-install_samba_ad.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ network:
3434
via: ${PRIMARY_DC_GATEWAY_IP}
3535
nameservers:
3636
search: [${REALM}]
37-
addresses: [${PRIMARY_DC_GATEWAY_IP}]
37+
addresses: [${PRIMARY_DC_FORWARDER_DNS}]
3838
EOF
3939
chmod 600 /etc/netplan/99-${PRIMARY_DC_INTERFACE}-static-${PRIMARY_DC_IP}.yaml
4040
netplan apply
@@ -92,7 +92,8 @@ rm -f /var/lib/samba/private/*.tdb
9292
echo "Provisioning Samba AD..."
9393
samba-tool domain provision --use-rfc2307 --realm="${REALM}" --domain="${DOMAIN}" \
9494
--server-role=dc --dns-backend=SAMBA_INTERNAL --adminpass="${ADMIN_PASSWORD}" \
95-
--option="interfaces=127.0.0.1 ${PRIMARY_DC_IP}" --option="bind interfaces only=yes"
95+
--option="interfaces=127.0.0.1 ${PRIMARY_DC_IP}" --option="bind interfaces only=yes" \
96+
--option="dns forwarder=${PRIMARY_DC_FORWARDER_DNS}"
9697

9798
# 11. Copy Kerberos configuration
9899
echo "Configuring Kerberos..."

setup_ubuntu-active-directory/2-join_additional_dc.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ echo "Joining domain as additional DC..."
9494
samba-tool domain join ${REALM} DC -U"administrator%${ADMIN_PASSWORD}" \
9595
--option="interfaces=127.0.0.1 ${SECONDARY_DC_IP}" \
9696
--option="bind interfaces only=yes" \
97+
--option="idmap_ldb:use rfc2307 = yes" \
98+
--option="dns forwarder=${SECONDARY_DC_FORWARDER_DNS}" \
9799
--dns-backend=SAMBA_INTERNAL
98100

99101
# 11. Copy Kerberos configuration

setup_ubuntu-active-directory/2-join_additional_rodc.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ echo "Joining domain as additional DC..."
9494
samba-tool domain join ${REALM} RODC -U"administrator%${ADMIN_PASSWORD}" \
9595
--option="interfaces=127.0.0.1 ${SECONDARY_DC_IP}" \
9696
--option="bind interfaces only=yes" \
97+
--option="idmap_ldb:use rfc2307 = yes" \
98+
--option="dns forwarder=${SECONDARY_DC_FORWARDER_DNS}" \
9799
--dns-backend=SAMBA_INTERNAL
98100

99101
# 11. Copy Kerberos configuration

setup_ubuntu-active-directory/env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ PRIMARY_DC_IP="10.10.20.220"
77
PRIMARY_DC_INTERFACE="enp1s0"
88
PRIMARY_DC_NETWORK="10.10.20.0/24"
99
PRIMARY_DC_GATEWAY_IP="10.10.20.1"
10+
PRIMARY_DC_FORWARDER_DNS="${PRIMARY_DC_GATEWAY_IP}"
1011
PRIMARY_DC_PTR_ADDRESS="20.10.10.in-addr.arpa"
1112

1213
# Secondary DC Configuration
@@ -15,6 +16,7 @@ SECONDARY_DC_IP="10.10.20.221"
1516
SECONDARY_DC_INTERFACE="enp1s0"
1617
SECONDARY_DC_NETWORK="10.10.20.0/24"
1718
SECONDARY_DC_GATEWAY_IP="10.10.20.1"
19+
SECONDARY_DC_FORWARDER_DNS="${SECONDARY_DC_GATEWAY_IP}"
1820
SECONDARY_DC_PTR_ADDRESS="20.10.10.in-addr.arpa"
1921

2022
# Domain Admin Password (change this!)

0 commit comments

Comments
 (0)