Daily tip

How to transparently redirect HTTP requests on port 80 to a http proxy on port 8080?

By using the iptable nat

First pre-requisite is enabling IP forwarding on the system

#echo “net.ipv4.conf.all.forwarding =1”>>/etc/sysctl.conf && sysctl -p

Then issue the below iptable command

#iptables -t nat -A PREROUTING -p tcp –dport 80 -j REDIRECT –to-port 8080


Daily tip

I have installed CentOS minimal and the commands, ifconfig, netstat and traceroute are not recognized: how come?

These are considered now deprecated or legacy commands/utilities, please get more info on their equivalent (in the order):

ip
ss
tracepath

Daily tip.

How do I display a substring of a variable in bash?

For example, you want to display the first seven characters from a string passed from the command line

echo ${$1:0:7}

Of course you can also save the value somewhere

substr=${$1:0:7}

Daily tip

How do I revoke a certificate in Openssl?

#openssl -ca revoke openssl ca -revoke /etc/ssl/certs/cert.pem

Of course replace path and filename to reflect your configuration.

Daily tips

How to prevent changing SELinux policy?

#setsebool secure_mode_policyload on

After that the SELinux policy (enforced or permissive) can be changed only after rebooting


Daily tip

How do I troublshoot the CIFS client in Linux?

Please activate tracing and debugging of the module cifs.ko by running these commands as root

#echo 1 > /proc/fs/cifs/traceSMB
#echo 7 > /proc/fs/cifs/cifsFYI

Then run dmesg to check for info