Ubiquity EdgeMAX EdgeRouter Lite PPPoE RDS-RCS NAT

So I got a new router to play with .. which looks awesome so far !
Here’s what I did to set up my connection !

configure 
set interfaces eth0 description WAN
set interfaces eth0 pppoe 0 default-route auto
set interfaces eth0 pppoe 0 mtu 1492
set interfaces eth0 pppoe 0 name-server none # you can use 'auto' if you want to use their ns's, I have my own.
set interfaces eth0 pppoe 0 user-id XXXXX
set interfaces eth0 pppoe 0 password XXXXX
set interfaces eth2 description LAN
set interfaces eth2 address 192.168.1.1/24
set firewall options mss-clamp interface-type pppoe
set firewall options mss-clamp mss 1412
set service nat rule 5000 outbound-interface pppoe0
set service nat rule 5000 type masquerade
set system offload ipv4 forwarding enable
set system offload ipv4 pppoe enable # this is the magic word that will offload pppoe from the processor to the ASIC or whatever it is !!!
set system offload ipv6 forwarding enable
set system offload ipv6 pppoe enable
set firewall port-forward lan-interface eth2
set firewall port-forward hairpin-nat enable # this will enable machines in the lan to use the wan to connect back to themselves
set firewall port-forward auto-firewall enable
set firewall port-forward rule 1 description apache
set firewall port-forward rule 1 forward-to address 192.168.1.10
set firewall port-forward rule 1 forward-to port 80
set firewall port-forward rule 1 original-port 80
set firewall port-forward rule 1 protocol tcp
set system host-name somehostname.dyn.com # change this
set system name-server 192.168.1.95 # you don't need this if you use auto on the pppoe connection.
set system time-zone Europe/Bucharest
commit
save

vim justify

So, I got some text that I needed to look pretty, meaning all lines should be 96 chars wide but if more than 10 spaces would be needed to added in each line between words, it should remain the same… SO I looked at column, par, fmt, emacs .. then settled on vim !

mkdir ~/.vim
wget http://ftp.stust.edu.tw/vim/runtime/macros/justify.vim -O ~/.vim/justify.vim
echo "so ~/.vim/justify.vim" >> ~/.vimrc
shift v # this will start visual selection mode
shift g # this will put you at the end of the file
:'<,'>Justify 96 10

image magick tricks

So, I had a couple of hundred images with the same background but people were in it in various places, I wanted to get the “average” background .. basically, getting the people out of the picture.

You need to have multiple pictures of the exact same thing for this to work. Photoshop has a thing called “image statistics” with an option called “median”.

convert *.jpg -evaluate-sequence median OUT.jpg

Then I wanted to remove some black things from the image and just replace them with white. Since there was a lil’ bit of “black-ish” around the black, the -fuzz helped.

convert OUT.jpg -fuzz 18% -fill white -opaque black OUT2.jpg

http proxy ipv4 only for yum

So, I needed a fast way to install dovecot on a centos 7 server in a private network that had access to my own network but not to the internet.

I set up a proxy and then saw that yum wants to use ipv6 here’s what I did

export http_proxy="http://198.51.100.13:3128"
echo 'ip_resolve=4'>> /etc/yum.conf
sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1
yum update