DynamicDNS with pfSense and Cloudflare
Setup Cloudflase
This guide is going to assume you already have the domain setup on CloudFlare.
- Login into Cloudflare
- Select your username in the top right and select “My Settings”
- Scroll down to the “API Key” section and select “View API Key” for “Global API Key”
- Copy the API Key you will need this in the next section.
Setup DynamicDNS for Cloudflare on pfSense
- Login into pfSense
- Select “Services” then “Dynamic DNS” and then select “Add”
- Select “Cloudflare” from “Service Type” drop down menu
- Select “WAN” for “Interface to monitor”
- Enter “<domain>” into hostname
- Enter Cloudflare username into username
- Enter Cloudflase API key from above into password
- Select “Save” then “Save and Force Update”
Install/Setup FreeIPA on CentOS 7 64-bit
- hostnamectl set-hostname <domain> –static
- reboot
- yum update -y && yum upgrade -y
- yum install epel-release -y && yum update -y
- yum install vim net-tools htop -y
- yum install ipa-server ipa-server-dns -y
- vim /etc/hosts
- Add “<IP addr of freeipa> <hostname> <hostname>.<domain>”
- save, exit
- ipa-server-install –setup-dns
- Enter “<hostname>.<domain>” for hostname
- Enter “<domain>” for domain
- Enter “<DOMAIN>” for realm
- The domain must be capitalized
- Enter a password for directory manager password
- Enter a password for FreeIPA admin
- Enter “<IP addr of FreeIPA>” for IP address for the associated hostname, press enter
- Enter “yes” to setup DNS forwarders.
- Enter DNS servers you want to request from
- Google DNS: 8.8.8.8, 8.8.4.4
- OpenDNS: 208.67.222.222, 208.67.220.220
- Use GRC DNS Benchmark to pick the best DNS server for you.
- Enter “yes” to reconfigure reverse zone
- Accept default for reverse zone name
- Enter “yes” to configure system with these values
Install/Setup Postfix to forward e-mails
- yum remove -y sendmail
- yum install -y postfix
- yum install -y mailx
- sed -i ‘s/inet_interfaces = localhost/inet_interfaces = all/g’ /etc/postfix/main.cf
- echo “virtual_alias_domains = <domain>” >> /etc/postfix/main.cf
- echo “virtual_alias_maps = hash:/etc/postfix/virtual” >> /etc/postfix/main.cf
- echo “@<domain> <e-mail to forward to>” >> /etc/postfix/virtual
- postmap /etc/postfix/virtual
- systemctl enable postfix
- systemctl restart postfix
Install/Setup FirewallD
- yum install firewalld -y
- systemctl enable firewalld
- systemctl start firewalld
- firewall-cmd –set-default-zone=internal
- firewall-cmd –permanent –add-service=ssh
- firewall-cmd –permanent –add-service=dns
- firewall-cmd –permanent –add-service=smtp
- firewall-cmd –permanent –add-service=ntp
- firewall-cmd –permanent –add-service=http
- firewall-cmd –permanent –add-service=https
- firewall-cmd –permanent –add-service=ldap
- firewall-cmd –permanent –add-service=ldaps
- firewall-cmd –permanent –add-service=kerberos
- firewall-cmd –permanent –add-service=kpasswd
- firewall-cmd –reload
Add first user
- Browse to “https://<hostname>.<domain>”
- Select “Identity” then “Users” and then select “Add”
- Enter username
- Enter first name
- Enter last name
- Select “admins” from dropdown menu for GID
- Enter password
- Select “add”
- Select the newly created user account.
- This page allows you to enable
- OTP(Google Two factor)
- user default shell
- Upload public key
- Add user certificate
- Add user to groups
- This page allows you to enable
Setup Google 2FA on FreeIPA accounts
- Select “Identity” then “Users”
- Select the user you wish to enable 2FA on
- Under “User authentication types” check ” Two factor authentication (password + OTP)”
- Select “Save” at the top.
- Select “Authentication” then “OTP Tokens” and then “Add”.
- From the drop-down menu select the user for the OTP token.
- Select “add”
- The next page should pop up a QR code.
- Logout of the FreeIPA Web GUI
- Login with username “testuser” and password “<password><OTP key>”
- Example
- username: testuser
- Password: password
- OTP: 784598
- Login
- Username: testuser
- Password: password784598
- Username: testuser
- Example
Install/Setup FreeIPA Client on CentOS 7 client
- yum -y install ipa-client
-
nmcli c modify eno16777736 ipv4.dns 10.0.0.30
-
nmcli c down eno16777736; nmcli c up eno16777736
- ipa-client-install
- Enter “yes” to continue with values
- Enter username that can add user to the domain
- Default user: admin
- authconfig –enablemkhomedir –update
- configure mkhomedir if you need ( homedirs of users are created at inital login )
- exit
- Login as domain user
Resources/Sources
- https://community.jisc.ac.uk/library/janet-services-documentation/how-block-or-sinkhole-domains-bind
- https://www.unixmen.com/configure-freeipa-server-centos-7/
- https://www.linode.com/docs/security/firewalls/introduction-to-firewalld-on-centos
- https://www.server-world.info/en/note?os=CentOS_7&p=ipa&f=3
Hey! Great post.
Can I use OTP only for(for example) ssh connection for one server and disable OTP for FreeIpa web interface?
To be honest I don’t know, I haven’t tried. However, I would assume OTP are assigned to accounts to it’s based on accounts.