https://github.com/shadowsocks/shadowsocks-libev
http://openwrt-dist.sourceforge.net/releases/ar71xx/packages/
opkg install iptables-mod-tproxy
opkg install shadowsocks-libev-spec_x.x.x_ar71xx.ipk
customer rule:
# Create new chain
iptables -t nat -N SHADOWSOCKS
iptables -t mangle -N SHADOWSOCKS
# Ignore your shadowsocks server's addresses
# It's very IMPORTANT, just be careful.
iptables -t nat -A SHADOWSOCKS -d 45.78.42.235 -j RETURN
# Ignore LANs and any other addresses you'd like to bypass the proxy
# See Wikipedia and RFC5735 for full list of reserved networks.
# See ashi009/bestroutetb for a highly optimized CHN route list.
iptables -t nat -A SHADOWSOCKS -d 0.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 10.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 127.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 169.254.0.0/16 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 172.16.0.0/12 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 192.168.0.0/16 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 224.0.0.0/4 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 240.0.0.0/4 -j RETURN
# Anything else should be redirected to shadowsocks's local port
iptables -t nat -A SHADOWSOCKS -p tcp -j REDIRECT --to-ports 8080
# Add any UDP rules
ip rule add fwmark 0x01/0x01 table 100
ip route add local 0.0.0.0/0 dev lo table 100
iptables -t mangle -A SHADOWSOCKS -p udp --dport 53 -j TPROXY --on-port 8080 --tproxy-mark 0x01/0x01
# Apply the rules
iptables -t nat -A PREROUTING -p tcp -j SHADOWSOCKS
iptables -t mangle -A PREROUTING -j SHADOWSOCKS
# Start the shadowsocks-redir
ss-redir -u -c /etc/config/shadowsocks.json -f /var/run/shadowsocks.pid
SyntaxHighlighter
2016年8月8日星期一
2015年6月21日星期日
Arch Linux install procedure
2015-6-20
https://wiki.archlinux.org/
Pre-installation
fdisk
mkfs.ext4 -j /dev/sda1
mount /dev/sda1 /mnt
wifi-menu #connect to internet
Installation
# cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
# sed -i 's/^#Server/Server/' /etc/pacman.d/mirrorlist.backup
# rankmirrors -n 6 /etc/pacman.d/mirrorlist.backup > /etc/pacman.d/mirrorlist
pacstrap /mnt base
Configure the system
genfstab -p /mnt >> /mnt/etc/fstab
arch-chroot /mnt
echo computer_name > /etc/hostname
ln -sf /usr/share/zoneinfo/Asia/Chongqing /etc/localtime
vi /etc/locale.gen # uncomment en_US.UTF-8
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
mkinitcpio -p linux
pacman -S grub
grub-install --target=i386-pc --recheck --debug /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg
passwd
pacman -S openssh
pacman -S wpa_actiond ifplugd wpa_supplicant dhcpcd dialog ppp #wifi-menu need
exit
umount -R /mnt
shutdown -r now
Configure after Arch install
systemctl enable sshd
wifi-menu -o #setup wifi after reboot
systemctl enable netctl
pacman -S net-tools #ifconfig netstat
systemctl enable systemd-timesyncd
Audio
pacman -S alsa-utils
useradd -m jejer
usermod -aG audio jejer
#alsamixer
X
pacman -S xorg-server # reinstall if you add user after xorg-server install
pacman -S ttf-droid # Chinese font
pacman -S tigervnc # for VNC server
vi ~/.vnc/xstartup
#!/bin/sh
export XKL_XMODMAP_DISABLE=1
exec startxfce4
xfce
pacman -S xfce4
startxfce4 #start X with xfce window manager manually
fcitx pinyin
pacman -S fcitx-im
pacman -S fcitx-configtool #configure for GTK
pacman -S fcitx-googlepinyin
PS:
setup proxy for some applications:
export ALL_PROXY="socks5://192.168.88.3:8080"
FIX Problem with pacman update - Signature is unknown trust
rm -R /etc/pacman.d/gnupg
pacman-key --init
pacman-key --populate archlinux
https://wiki.archlinux.org/
Pre-installation
fdisk
mkfs.ext4 -j /dev/sda1
mount /dev/sda1 /mnt
wifi-menu #connect to internet
Installation
# cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
# sed -i 's/^#Server/Server/' /etc/pacman.d/mirrorlist.backup
# rankmirrors -n 6 /etc/pacman.d/mirrorlist.backup > /etc/pacman.d/mirrorlist
pacstrap /mnt base
Configure the system
genfstab -p /mnt >> /mnt/etc/fstab
arch-chroot /mnt
echo computer_name > /etc/hostname
ln -sf /usr/share/zoneinfo/Asia/Chongqing /etc/localtime
vi /etc/locale.gen # uncomment en_US.UTF-8
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
mkinitcpio -p linux
pacman -S grub
grub-install --target=i386-pc --recheck --debug /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg
passwd
pacman -S openssh
pacman -S wpa_actiond ifplugd wpa_supplicant dhcpcd dialog ppp #wifi-menu need
exit
umount -R /mnt
shutdown -r now
Configure after Arch install
systemctl enable sshd
wifi-menu -o #setup wifi after reboot
systemctl enable netctl
pacman -S net-tools #ifconfig netstat
systemctl enable systemd-timesyncd
Audio
pacman -S alsa-utils
useradd -m jejer
usermod -aG audio jejer
#alsamixer
X
pacman -S xorg-server # reinstall if you add user after xorg-server install
pacman -S ttf-droid # Chinese font
pacman -S tigervnc # for VNC server
vi ~/.vnc/xstartup
#!/bin/sh
export XKL_XMODMAP_DISABLE=1
exec startxfce4
xfce
pacman -S xfce4
startxfce4 #start X with xfce window manager manually
fcitx pinyin
pacman -S fcitx-im
pacman -S fcitx-configtool #configure for GTK
pacman -S fcitx-googlepinyin
PS:
setup proxy for some applications:
export ALL_PROXY="socks5://192.168.88.3:8080"
FIX Problem with pacman update - Signature is unknown trust
rm -R /etc/pacman.d/gnupg
pacman-key --init
pacman-key --populate archlinux
2015年6月5日星期五
Enable UTF-8 support for linkstation
Add LANG=en_US.UTF-8 in /root/.bashrc
-------------------
proftpd fix
1. create /root/ftpd.sh according to /etc/init.d/ftpd.sh
add function
force_utf8()
{
if [ -f /etc/proftpd/proftpd.conf ]; then
cp /etc/proftpd/proftpd.conf /etc/proftpd/proftpd.conf.original
sed -i -e 's/CP936/UTF-8/g' /etc/proftpd/proftpd.conf
fi
sync
sleep 1
}
add force_utf8 call in start()
2. create S99_fix_ftp.sh in /etc/rc.d/extensions.d
and chmod +x S99_fix_ftp.sh
root@ls-qvl:/etc/rc.d/extensions.d# cat S99_fix_ftp.sh
-------------------
proftpd fix
1. create /root/ftpd.sh according to /etc/init.d/ftpd.sh
add function
force_utf8()
{
if [ -f /etc/proftpd/proftpd.conf ]; then
cp /etc/proftpd/proftpd.conf /etc/proftpd/proftpd.conf.original
sed -i -e 's/CP936/UTF-8/g' /etc/proftpd/proftpd.conf
fi
sync
sleep 1
}
add force_utf8 call in start()
#! /bin/sh # KIND="FTPD" FTPDOPTIONS= RETVAL=0 if [ -f /etc/melco/info ]; then . /etc/melco/info fi configure() { if [ -f /etc/linkstation_release ]; then ## configure files from Buffalo parameters. echo "configure ftpd" /usr/local/sbin/nas_configgen -c proftpd if [ $? -ne 0 ]; then echo "$0 configure fail" exit 1 fi fi sync sleep 1 } force_utf8() { if [ -f /etc/proftpd/proftpd.conf ]; then cp /etc/proftpd/proftpd.conf /etc/proftpd/proftpd.conf.original sed -i -e 's/CP936/UTF-8/g' /etc/proftpd/proftpd.conf fi sync sleep 1 } start() { if [ "$ftp" != "on" ] ; then echo "ftp is OFF" exit 0 fi configure force_utf8 echo -n $"Starting $KIND services: " /usr/local/sbin/proftpd $FTPDOPTIONS RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ftpd || \ RETVAL=1 return $RETVAL } stop() { echo -n $"Shutting down $KIND services: " killall proftpd RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ftpd echo "" return $RETVAL } restart() { stop start } reload() { echo -n $"Reloading proftpd.conf file: " killall -HUP proftpd RETVAL=$? echo return $RETVAL } # # Usage statement. # case "$1" in start) start ;; stop) stop ;; restart) restart ;; reload) reload ;; *) echo "usage: $0 {start|stop|restart|reload}" exit 1 ;; esac
2. create S99_fix_ftp.sh in /etc/rc.d/extensions.d
and chmod +x S99_fix_ftp.sh
root@ls-qvl:/etc/rc.d/extensions.d# cat S99_fix_ftp.sh
#! /bin/sh # /bin/cp /root/ftpd.sh /etc/init.d/ftpd.sh /etc/init.d/ftpd.sh restart
2015年5月16日星期六
Custom Sleep for LS-QVL
1. Set linkstation to auto mode.
2. Add crontab to run this script every 2mins
*/2 * * * * /root/custom_sleep.sh
How to WOL:
1. Python2
3. dd-wrt router
2. Add crontab to run this script every 2mins
*/2 * * * * /root/custom_sleep.sh
root@ls-qvl:~# cat custom_sleep.sh #!/bin/bash ################################################################################ # # CUSTOM_SLEEP by brumi 2010-07-16 # ################################################################################ # NOTE: please run this script every 2mins by crontab # This cron-job is intended to be used as replacement for the provided standby- # mechanism from buffalo. It checks for open connections and only when there are # no open connections found for a certain period of time it will put the link- # station into standby. TIMEOUT=1800 # wait TIMEOUT seconds before going to standby CONN_FILE=/var/run/connected # file to store timestamp LOG_FILE=/var/log/custom_sleep # log-file ENABLE_LOG='yes' # enable logging [yes|no] # ip addresses to exclude from the connection-check (i.e., local ones) OWN_IPADDR=`/bin/ipaddr show eth0 | /bin/grep -o -e "inet [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | /bin/sed s/"inet "//` EXCLUDE_IPADDR=(${OWN_IPADDR} 0.0.0.0 127.0.0.1 239.255.255.250 192.168.88.255) EXCLUDE_IPADDR_CT=5 # disable sleep in manual mode auto_pwr_stat=`cat /proc/buffalo/gpio/switch/auto_power` if [ "$auto_pwr_stat" != "on" ]; then if [ $ENABLE_LOG == 'yes' ]; then echo -n `date` >> $LOG_FILE echo ": custom_sleep: not in auto mode, exit" >> $LOG_FILE fi exit 0 fi # do nothing if already sleeping if [ -f /etc/linkstation_standby ]; then if [ $ENABLE_LOG == 'yes' ]; then echo -n `date` >> $LOG_FILE echo ": custom_sleep: already sleeping" >> $LOG_FILE fi exit 0 fi # function to check if any clients are connected connected () { CONN_IPADDR=`/bin/netstat -tna 2> /dev/null | /bin/sed s/"[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*"/"&\n"/ | /bin/grep -o -e "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*"` for ip in $CONN_IPADDR do exclude=0 for ((i=0;i<$EXCLUDE_IPADDR_CT;i++)) do if [ ${EXCLUDE_IPADDR[$i]} == $ip ]; then exclude=1 fi done if [ $exclude -eq 0 ]; then if [ $ENABLE_LOG == 'yes' ]; then echo -n `date` >> $LOG_FILE echo ": custom_sleep: active ip $ip" >> $LOG_FILE fi return 1 fi done return 0 } # check for connections and update $CONN_FILE connected if [ $? -eq 1 ]; then if [ -f $CONN_FILE ]; then rm $CONN_FILE fi else if [ ! -f $CONN_FILE ]; then date +%s > $CONN_FILE fi fi # check when last connection was found if [ -f $CONN_FILE ]; then last_conn=`/bin/cat $CONN_FILE` comp_time=`/bin/date +%s` let "comp_time -= $TIMEOUT" if [ $last_conn -gt $comp_time ]; then /usr/local/sbin/pwrmgr -c localhost act if [ $ENABLE_LOG == 'yes' ]; then echo -n `date` >> $LOG_FILE echo ": custom_sleep: wait-after-connection prevented standby" >> $LOG_FILE fi exit 0 fi else /usr/local/sbin/pwrmgr -c localhost act if [ $ENABLE_LOG == 'yes' ]; then echo -n `date` >> $LOG_FILE echo ": custom_sleep: connections prevented standby" >> $LOG_FILE fi exit 0 fi # no one busy -> clear timestamp and STANDBY if [ $ENABLE_LOG == 'yes' ]; then echo -n `date` >> $LOG_FILE echo ": custom_sleep: going to standby" >> $LOG_FILE fi rm $CONN_FILE /usr/local/sbin/pwrmgr -u
How to WOL:
1. Python2
#!/usr/bin/env python2 import socket import time bcast_addr = '192.168.88.255' # broadcast address for you network target_mac = "4C:E6:76:E7:xx:xx" # colons are optional, case does not matter mac = target_mac.replace(':', "") mac_bytes = "".join([chr(int(mac[i:i+2], 16)) for i in range(0, len(mac), 2)]) WoL_packet = '\xff'*6 + mac_bytes * 16 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) while 1: s.sendto(WoL_packet, (bcast_addr, 9)) print "Sent paket!" time.sleep(180)2. ArchLinux
- pacman -S wol
3. dd-wrt router
- Administration -- WOL -- Manual WOL, with port 9
订阅:
博文 (Atom)