Skip to content

Instantly share code, notes, and snippets.

View laetrid's full-sized avatar

Alex Kovalev laetrid

  • CloudDC
  • Moscow
View GitHub Profile
@laetrid
laetrid / vagrant_destroy_all_vm
Created September 1, 2016 15:43
How to destroy all Vagrant's VM
for i in $(vagrant global-status | grep running | awk '{ print $1 }'); do vagrant destroy -f $i; done
@laetrid
laetrid / ovpn_one_file_config
Created June 30, 2016 09:07
One file ovpn config
#To create one config file with ovpn certificates one need:
ca ca.crt
# change to
<ca>
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
</ca>
# all keys and crts the same way
# except for
@laetrid
laetrid / basic_iptables
Created June 28, 2016 16:32
Basic iptables config for newly installed Linux
# list iptables rules
iptables -L -vn
# flush iptables in chain, or everywhere if run without chain name
iptables -F
# change dafault chane rule
iptables -P FORWARD DROP
# append a new rule
iptables -A INPUT -p tcp -s 185.51.156.255 -j ACCEPT
# insert a new rule (here in 12th position)
iptables -I INPUT 12 -s 10.18.129.11/32 -j ACCEPT
@laetrid
laetrid / fast_ping_timestamp
Created January 19, 2016 12:35
Fast ping with timestamp
ping 8.8.8.8 -i 0.01 | while read pong; do echo "$(date +%H:%M:%S:%N): $pong"; done
brctl addbr br1
brctl stp br1 off
ip l set dev br1 up
And enable lldp:
echo 16384 > /sys/class/net/br1/bridge/group_fwd_mask
@laetrid
laetrid / add_user_on_srv
Last active September 13, 2016 08:38
Add user
## Debian
# /usr/sbin/adduser <username>
# sudo adduser <username> sudo
# chage -d 0 <username>
## RedHat
# /usr/sbin/adduser -c "Full Name" <username>
# gpasswd -a <username> wheel
# passwd <username>
# chage -d 0 <username>
@laetrid
laetrid / GetPass
Created November 10, 2015 11:06
Snaps for python
import getpass
PASSWORD = getpass.getpass('Enter password : ')
man script
To record all new bash sessions:
Add:
test "$(ps -ocommand= -p $PPID | awk '{print $1}')" == 'script' || (script -t 2> $HOME/shell_logs/$(date +"%Y-%m-%d_%H%M%S").timing -f $HOME/shell_logs/$(date +"%Y-%m-%d_%H%M%S").log)
to $HOME/.bashrc
And create directory $HOME/shell_logs/
sudo modprobe 8021q
lsmod | grep 8021q
ip link add link eth1 name eth1.10 type vlan id 10
https://dougvitale.wordpress.com/2011/12/21/deprecated-linux-networking-commands-and-their-replacements/
@laetrid
laetrid / gist:772a9d62a9556c0a18bd
Created June 19, 2015 13:21
USB GSM modem in VyOS
# Rename usb0 to eth1
# in /etc/udev/rules.d/70-persistent-net.rules
KERNEL=="usb0", NAME="eth1"