Part III - The Ultimate Linux Home Router - Active Directory on openSUSE using Samba 4.1
Friday, December 20, 2013Compiling the Latest Version of Samba 4
Samba 4 is the first version of Samba to adequately host Active Directory without the need for an expensive Windows Server. Though it's been in the wild for a while now, it's still got some rough points. I've been using it for a few months now and the only issues I've run into have been centered purely around Microsoft applications that require schema updates to function. I'm running it with a single domain controller, so I've not tried to get replication functional (this is, after all, just a home network).There are samba packages in the Tumbleweed repository, but at this point in time they are not at the version I needed, so we'll be compiling from the source. Parts of this entry were adapted from Conrad Jones blog. Much thanks to him for publishing that. Run the following commands (make, gcc and binutils will already be present if you opted to install fish):
1 | # zypper install make gcc binutils autogen krb5-devel krb5-client nano libacl-devel acl attr python python-devel |
1 | # reboot |
1 2 3 4 5 6 7 | $ su (Enter your password) # cd ~ # tar -xvf samba-4.1.3.tar.gz # cd samba-4.1.3/ # ./configure; and make; and make install |
After about ten minutes, you should be compiled and ready to start configuring Samba and creating your new Active Directory domain.
Note: If you're wondering why the compile command issued was ./configure; and... instead of ./configure &&..., && is one of a handful of things fish shell doesn't support. If you're going to switch your shell to fish long-term, keep that in mind when viewing articles that have linux commands embedded. The syntax above will work in fish and bash.
Creating Samba Service Definition
1 | # nano /usr/lib/systemd/system/samba.service |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | [Unit] Description=Samba AD Daemon After=syslog.target network.target [Service] Type=forking PIDFile=/usr/local/samba/var/run/samba.pid LimitNOFILE=16384 EnvironmentFile=-/etc/sysconfig/samba ExecStart=/usr/local/samba/sbin/samba $SAMBAOPTIONS ExecReload=/usr/bin/kill -HUP $MAINPID [Install] WantedBy=multi-user.target |
Now we'll create a symbolic link to the service and configure it to run at startup
1 2 | # ln -s /usr/lib/systemd/system/samba.service /etc/systemd/system/samba.service # systemctl enable samba |
Installing BIND 9 (Optional, use BIND 9 backend)
Personally, I prefer to stick with BIND over the default SAMBA DNS. It's rock solid, configurable, and there's a ton of information on how to tweak it because it's so widely used. You can stick with the internal DNS implementation if you want (and it's certainly a lot fewer steps), but I elected to use BIND.1 | # zypper in bind |
Edit the configuration files
Now we need to add some parameters to the existing named.conf.1 | # nano /etc/named.conf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # BEGIN ---- Configuration Modifications auth-nxdomain yes ; # NOTE: These are the opendns.org DNS servers. I choose to use them instead # of the ones provided by my ISP. They're available globally so they # should work fine, however, if your ISP or router adds their own split-brain # DNS (U-Verse typically does this to make it easy to connect to your # router information page), you will not be able to connect to their # custom DNS entries. forwarders { 208.67.222.222; 208.67.220.220; }; allow-transfer { none; }; # IMPORTANT: Change the below to point to values appropriate for YOUR home network. # I used 192.168.0.0 for my wired internal network and 192.168.2.0 for # my guest wireless restricted internal network. allow-query { 127.0.0.0 /24 ; 192.168.0.0 /24 ; 192.168.2.0 /24 ; }; # IMPORTANT: You should only EVER let hosts sitting on the non-internet side # of your router allow recursion even if you allow queries from # external networks! allow-recursion { 127.0.0.0 /24 ; 192.168.0.0 /24 ; 192.168.2.0 /24 ; }; pid- file "/var/run/named/named.pid" ; empty-zones- enable no; # END ---- Configuration Modifications |
Modify the localhost Zone Files
1 2 3 | # rm /var/lib/named/localhost.zone # rm /var/lib/named/127.0.0.zone # nano /var/lib/named/localhost.zone |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | $TTL 1W $ORIGIN localhost. @ 1D IN SOA @ root ( 42 ; serial (d. adams) 8H ; refresh 2H ; retry 4W ; expiry 1D ; minimum ) @ IN NS @ IN A 127.0.0.1 IN AAAA ::1 |
1 | # nano /var/lib/named/127.0.0.zone |
1 2 3 4 5 6 7 8 9 10 11 12 13 | $TTL 1W @ IN SOA localhost. root.localhost. ( 42 ; serial (d. adams) 8H ; refresh 2H ; retry 4W ; expiry 1D ; minimum ) IN NS localhost. 1 IN PTR localhost. |
1 2 | # chown named:named /var/lib/named/*.zone # chmod 640 /var/lib/named/*.zone |
1 | # named -u named |
Configuring for hosting services on our Internal network
Now that we're actually going to HOST something and we have DNS setup, we need to stop requesting DHCP addresses. We're going to ignore wireless for now. I currently have only one network adapter plugged in since my other is USB based and I don't need it quite yet, so I'll be referring to the only adapter that I have. If you're following along with this from Part I, you should only have one cable plugged in and that should be your plugged into your internal network.1 | # yast |
You're on the Overview screen. Select the network adapter that represents your plugged-in Ethernet adapter and choose Edit.
Put an X next to Statically assigned IP Address and hit TAB
Set your IP address to the desired value and hit TAB. I'm using 192.168.0.1 since .1 is commonly the router IP address.
Set your Subnet Mask and hit TAB. I'm using 255.255.255.0.
Set your fully qualified host name. This will be the computer hostname and the domain name that corresponds with your DNS and Active Directory domain. Example: host.somedomain.com
Go to the General tab.
Make sure Assigned Interface to Firewall Zone is set to Internal Zone (unprotected)
Hit F10
Go to Hostname/DNS and select Name server 1
Set it to the IP address you assigned above.
Go to Routing and select Default IPv4 Gateway and set it to your current, functioning router's IP. Do the same for IPv6 if applicable.
Hit F10 and once.
... and ... it hangs (or disconnects)! You just changed your IP address. Reconnect, but use the IP address you just set.
1 2 3 4 5 | $ su (enter your password) # chkconfig -s named on # rcnamed start # rcnamed status |
1 | # host localhost. 127.0.0.1 |
1 2 3 4 5 6 | Using domain server: Name: 127.0.0.1 Address: 127.0.0.1#53 Aliases: localhost has address 127.0.0.1 |
1 | # host 127.0.0.1 127.0.0.1 |
1 2 3 4 5 6 | Using domain server: Name: 127.0.0.1 Address: 127.0.0.1#53 Aliases: 1.0.0.127.in-addr.arpa domain name pointer localhost. |
1 | # nslookup google.com |
Provisioning our Active Directory Domain
We'll use samba-tool to provision the domain.1 | # /usr/local/samba/bin/samba-tool domain provision --use-rfc2307 --interactive |
1 2 3 4 5 6 | Realm [YOURDOMAIN.NET]: Domain [YOURDOMAIN]: Server Role (dc, member, standalone) [dc]: DNS backend (SAMBA_INTERNAL, BIND9_FLATFILE, BIND9_DLZ, NONE) [SAMBA_INTERNAL]: BIND9_DLZ Administrator password: Retype password: |
Updating BIND configuration to include samba entries
1 | # nano /usr/local/samba/private/named.conf |
Save and exit.
1 | # nano /etc/named.conf |
1 | include "/usr/local/samba/private/named.conf"; |
And finally, we have to prevent BIND from running chrooted so that it can find the dlz_bind9_9.so file.
1 | nano /etc/sysconfig/named |
1 2 3 | # systemctl start samba # rcnamed restart # rcnamed status |
1 | # host -t SRV _ldap._tcp.yourdomain.net |
1 | _ldap._tcp.diagonactic.net has SRV record 0 100 389 yourdomaincontroller.yourdomain.net. |
Configuring Kerberos and testing your new domain
We need to be able to get kerberos tickets, so we're going to configure the kerberos client and give it a test.1 2 3 | # cp /usr/local/samba/private/krb5.conf /etc/krb5.conf # kinit administrator@YOURDOMAIN.NET (enter the password you provided in the samba-tool step above |
1 | # klist |
Configuring your server to backup your Active Directory environment
Especially since Active Directory support in Samba is relatively new and has bugs being fixed constantly, it's a good idea to have a backup because you'll probably be applying updates. And the fact that an AD domain is something that's usually in a state of flux, it's a good idea to get that started now.1 2 3 4 5 6 7 | # cp ~/samba-4.1.3/source4/scripting/bin/samba_backup /usr/sbin # chown root:root /usr/sbin/samba_backup # chmod 750 /usr/sbin/samba_backup # mkdir /usr/local/backups # chmod 750 /usr/local/backups # ln -s /usr/sbin/samba_backup /etc/cron.daily/samba_backup # nano /usr/sbin/samba_backup |
1 2 3 4 5 6 7 | for ldb in ` find $relativedirname -name "*.ldb" `; do tdbbackup $ldb if [ $? - ne 0 ]; then echo "Error while backuping $ldb" exit 1 fi done |
1 | /usr/local/samba/bin/tdbbackup $ldb |
1 2 | # /usr/sbin/samba_backup # ls /usr/local/backups |
Subscribe to:
Post Comments
(
Atom
)
Software
You should follow me on Twitter @matthewdippel. I post all kinds of mundane things!
Blog Archive
-
▼
2013
(
6
)
-
▼
December
(
6
)
- Part VI - The Ultimate Linux Home Router - SquidGu...
- Part V - The Ultimate Linux Home Router - Services...
- Part IV - The Ultimate Linux Home Router - DHCP an...
- Part III - The Ultimate Linux Home Router - Active...
- Part II - The Ultimate Linux Home Router - Tumblew...
- Part I - The Ultimate Linux Home (and possibly Sma...
-
▼
December
(
6
)