Rhce PDF
Rhce PDF
Rhce PDF
RHCE
Contents
System Configuration and Management 1
HTTP/HTTPS 10
DNS 15
NFS 16
SMB 19
DATABASE SERVICES 22
• Indicate that the teamed interface is manually configured with a static IP rather than DHCP:
»» nmcli con mod myteam0 ipv4.method manual
»» nmcli con add type team-slave con-name myteam0-port2 ifname eno2 master
myteam0
-1-
RHCE Study Guide Linux Academy
»» 128-bit number
»» Example: 3022:0cd8:0000:0100:0000:0000:0000:0001
• Short Hand
»» A group of all zeros in a nibble can be represented by colons alone, like so: 3022:0cd8:0:01::1
»» Cannot have two :: substitute shortcuts in any one address, regardless of grouping of zeros
»» Displays the current routing table, including static routes restored on boot
»» Replaces the netstat -rn command for showing routes, although that still works on all
distributions, as well, at this time
»» This adds a static route to the 192.168.1.0 network (addresses .1 through .254) via the
192.168.0.1 IP through device eth1
• /etc/sysconfig/network-scripts
»» Directory where files exist for interface and network routing persistence
»» Example:
–– route-eth1
ADDRESS0=192.168.1.0
-2-
RHCE Study Guide Linux Academy
NETMASK0=255.255.255.0
GATEWAY0=192.168.0.1
»» These will persistently create the same static route that was added dynamically with the route
command above
• Allows working with services, zones and rules, as well as importing custom rules from XML files
• Service configurations are stored in XML files located at /usr/lib/firewalld/services and /etc/
firewalld/services (depending on user-defined [/usr/lib] or system-level [/etc/firewalld]
definitions)
»» firewall-cmd –reload
»» –set default-zone
»» –get-active-zones
»» –get-zones
»» –list-all
»» –list-all-zones
»» –new-zone
»» –delete-zone
»» –permanent
»» –zone
»» Commands making rule changes of any kind are NOT persistent (in other words, will not
persist across reboots or service restarts) UNLESS the –permanent option is specified
»» Commands making rule changes take immediate effect UNLESS specifying the –permanent
-3-
RHCE Study Guide Linux Academy
»» –list-services
»» –query-service
»» –add-service
»» –remove-service
»» –new-service
»» –delete-service
»» –add-port
»» –remove-port
»» –query-port
• When adding ports, the port number must specify TCP/UDP for application
»» –add-rich-rule
»» –remove-rich-rule
»» –query-rich-rule
• Sample using rich rules to allow inbound HTTP access from a network IP range 10.0.1.0/24,
logging each one at the info log level and making the change permanent:
»» firewall-cmd –add-rich-rule 'rule-family="ipv4" source address="10.0.1.0/24"
service name="http" log prefix="HTTP Allow Rule" level="info" accept' –
permanent
»» This will update the default zone (public by default) XML rule file in /etc/firewalld/zones/
public.xml
»» –add-forward-port
-4-
RHCE Study Guide Linux Academy
»» –remove-forward-port
»» –query-forward-port
• Forwarding example for redirecting SSH from port 22 to port 2222 in the DMZ zone:
»» firewall-cmd –zone DMZ –permanent –add-forward-port
port=22:proto=tcp:toport=2222
• Making changes to a running kernel parameter can be done by manipulating the values within the
file pertaining to the section you wish to change; for example, to change the IPv4 forwarding value
in order to allow your system to function as a network gateway, you can do the following to effect an
immediate change:
»» echo 1 > /proc/sys/net/ipv4/ip_forward
»» net.ipv4.ip_forward = 1
–– sysctl -p
–– or reboot
»» KDC server
-5-
RHCE Study Guide Linux Academy
»» Client
»» Packages:
–– krb5-server
–– krb5-workstation
–– pam_krb5
• KDC server:
»» /var/kerberos/krb5kdc/kdc.conf
»» /etc/krb5.conf
»» /var/lib/krbkdc/kadm5.acl
»» Kerberos requires FQDN references; if you do not have FQDN or are on a private network, be
sure all clients and servers have the FQDN set to localhost (/etc/hosts) for those authenticating
to the KDC
»» If local: kadmin.local
»» If remote: kadmin
-6-
RHCE Study Guide Linux Academy
»» addprinc root/admin
–– Replace the server name and example.com with your own information
»» /etc/ssh/ssh_config
–– GSSAPIAuthentication yes
–– GSSAPIDelegateCredentials yes
• Client and user authentication (local KDC or separate client after user and host added as above):
»» su – user01
»» kinit
-7-
RHCE Study Guide Linux Academy
–– Note: No configuration has been made, target will start and stop
»» targetcli
• block backstore
»» targetcli
–– Note: No size is needed as it is determined by the device and partition size references
• Create a LUN:
»» fileio backstore
»» block backstore
• /etc/iscsi/initiatorname.iscsi
-8-
RHCE Study Guide Linux Academy
»» node.session.auth.username = username
»» node.session.auth.password = password
• /etc/fstab mounting:
»» get block id, blkid
–– _netdev indicates during boot to wait for full network availability before attempting mount
»» pgrep
»» top
»» ss
»» nmap
-9-
RHCE Study Guide Linux Academy
• Reporting options:
–– Will produce a report for the 15th of the month for CPU, memory, disk activity and
network (where DEV is the interface you want the report to apply to for activity)
HTTP/HTTPS
• Install and configure Apache:
»» httpd
»» /etc/httpd
–– Primary http configuration directory, all httpd configuration files and directories root here
»» /etc/httpd/conf
»» /etc/httpd/conf.d
–– User and index configuration file (user directory, welcome message and indexes)
»» /etc/httpd/conf.d.modules
»» /etc/httpd/logs
»» /etc/httpd/modules
- 10 -
RHCE Study Guide Linux Academy
»» /etc/httpd/run
»» /var/www/html
• /etc/httpd/conf/httpd.conf
»» <Directory "/var/www/html/private"> # Example
»» AuthType Basic
»» </Directory>
• Test configuration:
»» apachectl configtest
• Set permissions:
• Ownership to Apache:
»» chown apache:apache /etc/httpd/conf/passwd
- 11 -
RHCE Study Guide Linux Academy
• /etc/httpd/conf/httpd.conf
»» <Directory “/var/www/html/private”> # Example
»» AuthType Basic
»» </Directory>
• Test configuration:
»» apachectl configtest
• Set permissions:
»» chown 600 /etc/httpd/conf/passwd
• Ownership to Apache:
»» chown apache:apache /etc/httpd/conf/passwd
- 12 -
RHCE Study Guide Linux Academy
»» Include vhost.d/*.conf
• Externalizes vhost configuration; by default, vhost configurations can be added directly to httpd.
conf
»» /etc/httpd/vhost.d/myhost.sample.com_http.conf
–– <VirtualHost *:80>
–– ServerAdmin [email protected]
–– DocumentRoot /var/www/html/myhost.sample.com
–– ServerName myhost.sample.com
–– ServerAlias myhost
–– ErrorLog logs/myhost.sample.com-error_log
–– </VirtualHost>
• Apache must be restarted or reloaded gracefully to read the new virtual host:
»» systemctl restart httpd
• SELinux considerations:
»» getsebool httpd_enable_cgi
- 13 -
RHCE Study Guide Linux Academy
»» restorecon -R /mycgi
»» Replace ScriptAlias
»» AllowOverride None
»» Options None
»» </Directory>
• Apache must be restarted or reloaded gracefully to read the new virtual host
»» systemctl restart httpd
• System-wide certificate:
»» /etc/httpd/conf.d/ssl.conf
–– SSLCertificateFile /etc/httpd/ssl-certs/myhost.sample.co m.crt
- 14 -
RHCE Study Guide Linux Academy
• Test configuration:
»» httpd -t
»» apachectl configtest
• Certificates for specific virtual hosts: Add the following to virtual host file (in our configuration, in /
etc/httpd/vhost.d/myhost.sample.com_https.conf):
–– typical virtual host configurations for directories, server names, etc (see above)
–– SSLEngine on
• Apache must be restarted or reloaded gracefully to read the new virtual host:
»» systemctl restart httpd
DNS
Configure a Caching-Only Name Server
• Install the bind name server:
»» yum install -y bind
• /etc/named.conf
»» Change:
–– listen-on port 53 { 127.0.0.1; }; # replace 127.0.0.1 with ‘any’
–– dnssec-validation no;
- 15 -
RHCE Study Guide Linux Academy
–– named-checkconf
»» Testing:
–– nslookup google.com 127.0.0.1 # or local IP of server
–– dig
–– ping
NFS
Provide Network Shares to Specific Clients
• Group installation for server:
»» yum groupinstall -y file-server
• Apply permissions:
»» chmod 0777 /home/fileshare
• SELinux considerations:
–– setsebool -P nfs_export_all_rw on
–– setsebool -P use_nfs_home_dirs on
- 16 -
RHCE Study Guide Linux Academy
• /etc/exports
• Client installation:
»» yum install -y nfs-utils
• /etc/fstab
»» [servername/ip]:[/path/to/share] [/path/local/mountpoint] nfs options 0 0
# example below
• /etc/exports
- 17 -
RHCE Study Guide Linux Academy
–– /mygroup client.sample.com(rw,no_root_squash)
• SELinux considerations
–– setsebool -P nfs_export_all_rw on
–– setsebool -P use_nfs_home_dirs on
• Client installation:
»» yum install -y nfs-utils
• /etc/fstab
»» [servername/ip]:[/path/to/share] [/path/local/mountpoint] nfs options 0 0
# example below
- 18 -
RHCE Study Guide Linux Academy
• Using the KDC admin utility to add the appropriate NFS server configuration:
• /etc/exports
»» Add the option sec=krb5 insider the options for any export to be protected via Kerberos
–– /mygroup client.sample.com(rw,no_root_squash,sec=krb5)
• NFS secure client should have the pam and Kerberos packages
• Using the KDC admin utility, add the appropriate client configuration:
»» kadmin
»» ktadd nfs/client.sample.com
• RHEL 7.1+ systems need to enable and start the special nfs-client.target:
»» systemctl enable nfs-client.target
• /etc/fstab
»» [servername/ip]:[/path/to/share] [/path/local/mountpoint] nfs4 options
[sec=krb5] 0 0 # example below
SMB
- 19 -
RHCE Study Guide Linux Academy
• /etc/samba/smb.conf
»» browseable = yes
»» path = /path/to/your/share
»» writable = yes
»» Will show output for the configuration and share destination section
• Create the directory you indicated in your configuration for the share.
• SELinux considerations:
–– restorecon -R /myshare
- 20 -
RHCE Study Guide Linux Academy
• Create the user (if needed), create the samba password for the user account:
»» smbpasswd -a user01
SMTP
Configure a System to Forward All Email to a Central Mail
Server
• Install Postfix:
»» yum install -y postfix
• /etc/postfix/main.cf
»» Changes needed for scenario of network 10.0.1.0/24 and the mail server called mail.sample.
com on IP 10.0.1.100:
–– myhostname = mail.sample.com
–– mydomain = sample.com
–– myorigin = $mydomain
–– inet_interfaces = loopback-only
–– mydestination =
–– relayhost = 10.0.1.100
»» postconf -a
• Testing:
- 21 -
RHCE Study Guide Linux Academy
»» mailq
DATABASE SERVICES
Install and Configure MariaDB
• Install the service and client:
»» yum install -y mariadb mariadb-server
• /etc/my.cnf
• Backing up sample database called mydb using the root user on the localhost:
»» mysqldump –user=root password="password" –result-file=mydb.sql mydb
• Restoring the same database (note that the database itself MUST already exist, it will not recreate
the database with the above command backup):
»» mysql –user=root –password=”password” mydb < mydb.sql
- 22 -
RHCE Study Guide Linux Academy
• Create a simple user table with firstname, lastname and emails address fields, all string fields with
50 character limits
»» CREATE TABLE tblUserInfo(firstname varchar(50),lastname varchar(50),email
varchar(50));
• Insert records:
»» INSERT tblUserInfo VALUES(“John”,”Smith”,”[email protected]”);
- 23 -
RHCE Study Guide Linux Academy
- 24 -