- Install ssmtp
:
sudo apt-get install ssmtp - Edit the ssmtp config file:
gksu gedit /etc/ssmtp/ssmtp.conf - Append the following text:
root=username@gmail.com mailhub=smtp.gmail.com:465 rewriteDomain=gmail.com AuthUser=username AuthPass=password FromLineOverride=YES UseTLS=YES - Run ssmtp and provide the recipient email address:
ssmtp recepient_name@gmail.com - Provide the message details as follows:
To: recipient_name@gmail.com From: username@gmail.com Subject: Sent from a terminal! Your content goes here. Lorem ipsum dolor sit amet, consectetur adipisicing. (Notice the blank space between the subject and the body.)ssmtp recipient_name@gmail.com < filename.txt
Category Archives: Linux
Unibits SSL certs
Bought @ https://comodosslstore.com/
UC-GZ1 crontab
@reboot sleep 61; /sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 1852 -j DNAT --to-destination 192.168.0.61:1852 @reboot sleep 61; /sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j DNAT --to-destination 192.168.0.61:443 @reboot sleep 61; /sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 992 -j DNAT --to-destination 192.168.0.61:992 @reboot sleep 61; /sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 1194 -j DNAT --to-destination 192.168.0.61:1194 @reboot sleep 61; /sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 1852 -j DNAT --to-destination 192.168.0.61:1852 @reboot sleep 61; /sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 5555 -j DNAT --to-destination 192.168.0.61:5555 @reboot sleep 61; /sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 8888 -j DNAT --to-destination 192.168.0.61:8888 @reboot sleep 61; /sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 18106 -j DNAT --to-destination 192.168.0.61:18106 @reboot sleep 61; /sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 18158 -j DNAT --to-destination 192.168.0.61:18158 @reboot sleep 61; /sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 18208 -j DNAT --to-destination 192.168.0.61:18208 @reboot sleep 61; /sbin/iptables -t nat -A PREROUTING -i eth0 -p udp --dport 1852 -j DNAT --to-destination 192.168.0.61:1852 @reboot sleep 65; /usr/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
Switch to use different gateway according to the time
#!/bin/bash NOW=`date '+%H:%M:%S'` MORNINGTIME="06:00:00" NIGHTTIME="20:00:00" if [ $NOW > $MORNINGTIME ] && [[ $NOW < $NIGHTTIME ]] then /sbin/route add -net 0.0.0.0/1 gw 192.168.168.1 /sbin/route add -net 128.0.0.0/1 gw 192.168.168.1 /sbin/route del -net 0.0.0.0/1 gw 192.168.42.1 /sbin/route del -net 128.0.0.0/1 gw 192.168.42.1 echo "Use 192.168.168.1" else /sbin/route del -net 0.0.0.0/1 gw 192.168.168.1 /sbin/route del -net 128.0.0.0/1 gw 192.168.168.1 /sbin/route add -net 0.0.0.0/1 gw 192.168.42.1 /sbin/route add -net 128.0.0.0/1 gw 192.168.42.1 echo "Use 192.168.42.1" fi
Clean the docker cache
docker kill $(docker ps -q) docker_clean_ps docker rmi $(docker images -a -q)
Block the traffic of a particular IP using iptables
sudo iptables -A FORWARD -s IP-ADDRESS -j DROP
#!/bin/bash
# Check if an IP address is provided
if [ -z "$1" ]; then
echo "Usage: $0 <IP_ADDRESS>"
exit 1
fi
IP_ADDRESS=$1
echo "Blocking IP: $IP_ADDRESS"
# Add iptables rule to block the IP
sudo iptables -A INPUT -s $IP_ADDRESS -j DROP
echo "IP $IP_ADDRESS has been blocked."
Linux QoS traffic shaping
#! /bin/bash
NETCARD=eth0
MAXBANDWIDTH=100000
# reinit
tc qdisc del dev $NETCARD root handle 1
tc qdisc add dev $NETCARD root handle 1: htb default 9999
# create the default class
tc class add dev $NETCARD parent 1:0 classid 1:9999 htb rate $(( $MAXBANDWIDTH ))kbit ceil $(( $MAXBANDWIDTH ))kbit burst 5k prio 9999
# control bandwidth per IP
declare -A ipctrl
# define list of IP and bandwidth (in kilo bits per seconds) below
ipctrl[192.168.1.1]="256"
ipctrl[192.168.1.2]="128"
ipctrl[192.168.1.3]="512"
ipctrl[192.168.1.4]="32"
mark=0
for ip in "${!ipctrl[@]}"
do
mark=$(( mark + 1 ))
bandwidth=${ipctrl[$ip]}
# traffic shaping rule
tc class add dev $NETCARD parent 1:0 classid 1:$mark htb rate $(( $bandwidth ))kbit ceil $(( $bandwidth ))kbit burst 5k prio $mark
# netfilter packet marking rule
iptables -t mangle -A INPUT -i $NETCARD -s $ip -j CONNMARK --set-mark $mark
# filter that bind the two
tc filter add dev $NETCARD parent 1:0 protocol ip prio $mark handle $mark fw flowid 1:$mark
echo "IP $ip is attached to mark $mark and limited to $bandwidth kbps"
done
#propagate netfilter marks on connections
iptables -t mangle -A POSTROUTING -j CONNMARK --restore-mark
Reference link: https://serverfault.com/questions/191560/how-can-i-do-traffic-shaping-in-linux-by-ip
DNSMASQ China List
DHCP Server
dhcp-range=tap_unibits,100.64.0.10,100.64.7.250,255.255.248.0,5m dhcp-option=3,100.64.0.1 dhcp-option=6,8.8.8.8 dhcp-option=6,8.8.4.4
Path of Munin RRD files
/var/lib/munin
If all RRD files are deleted, the graph will be reset.