sudo nano /etc/apt/sources.list deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi # Uncomment line below then 'apt-get update' to enable 'apt-get source' #deb-src http://archive.raspbian.org/raspbian/ jessie main contrib non-free rpi deb http://repozytorium.mati75.eu/raspbian jessie-backports main contrib non-free #deb-src http://repozytorium.mati75.eu/raspbian jessie-backports main contrib non-free sudo nano /etc/apt/sources.list sudo apt-get update sudo gpg --keyserver pgpkeys.mit.edu --recv-key CCD91D6111A06851 sudo gpg --armor --export CCD91D6111A06851 | sudo apt-key add - Your Google OAUTH2 Code is 4/AADgC4tDx6bBe9Uor5kGYeZF7IgPBV2SR1LtLype7MMsofju5bY9BVlMPeVaqUww0ewEhdtQn39Ge4oOUBoyrr4 # m h dom mon dow command 02 06 * * * tar -zcf /var/backups/home.tgz /home/ 49 05 * * 2 sudo service snmpd stop 50 05 * * 2 sudo service vpnserver stop 52 05 * * 2 sudo reboot 49 05 * * 5 sudo service snmpd stop 50 05 * * 5 sudo service vpnserver stop 52 05 * * 5 sudo reboot ###03 07 * * * sudo iptables -A INPUT -p ICMP --icmp-type 8 -j DROP */5 * * * * sudo env LANG=C mrtg /etc/mrtg.cfg /etc/init.d/service start /etc/init.d/service enable sudo shutdown -r now #################################################### vcgencmd measure_clock 其中的 是指定要查詢的硬體, 可用的選項有 arm、 core、 h264、 isp、 v3d、 uart、pwm、 emmc、 pixel、 vec、 hdmi、 dpi。 vcgencmd codec_enabled 其中 是指定要查詢的 codec,可用的選項有: H264、 MPG2、 WVC1、 MPG4、 MJPG、 WMV9。 vcgencmd measure_clock arm vcgencmd measure_volts vcgencmd measure_temp vcgencmd get_config int vcgencmd get_mem arm vcgencmd get_mem gpu vcgencmd version vcgencmd commands #################################################### sudo mkdir /media/usb sudo chown -R hckao:hckao /media/usb sudo mount /dev/sda1 /media/usb -o uid=hckao,gid=hckao sudo umount /media/usb #################################################### root@raspberrypi:/usr/local/vpnserver# ./vpnserver start #; softether restart #################################################### pi@raspberrypi:~ $ lsb_release -a pi@raspberrypi:~ $ ~$ sudo apt-get install lsb-core -y #################################################### pi@raspberrypi:/etc $ nano dhcpcd.conf interface eth0 static ip_address=192.168.x.x static routers=192.168.x.x static domain_name_servers=8.8.8.8 static domain_search= #################################################### adduser -G sudo hckao sudo adduser sudo sudo userdel -r pi ####del user pi #################################################### sudo apt-get install pppoeconf ppp #安裝pppoeconf、ppp套件 等待安裝完成...等等等~ sudo pppoeconf #################################################### sudo service iptables status----------no data sudo iptables -L #################################################### *********************************************************** sudo iptables -A INPUT -p ICMP --icmp-type 8 -j DROP #阻止ping iptables -A INPUT -i $EXTIF -s 213.131.252.251 -j DROP #阻止後門程式連入 iptables -A INPUT -i $EXTIF -d 213.131.252.251 -j DROP #阻止後門程式連出 sudo iptables -F sudo iptables -X sudo iptables -Z sudo iptables -P INPUT ACCEPT sudo iptables -P OUTPUT ACCEPT sudo iptables -P FORWARD ACCEPT *********************************************************** #################################################### backup folder is /var/backups/home.tgz #################################################### 目前的rc.local,兩條 ##for pptp sudo iptables -t nat -A POSTROUTING -s 172.18.100.0/24 -o eth0 -j MASQUERADE ##disable icmp type 8 echo sudo iptables -A INPUT -p ICMP --icmp-type 8 -j DROP #################################################### systemctl daemon-reload #################################################### sudo apt-get install sysstat sar -u 1 5 #################################################### VCHI initialization failed sudo usermod -aG video #################################################### sudo update-rc.d bluetooth disable #################################################### # For more information see the manual pages of crontab(5) and cron(8) # # m h dom mon dow command 00 06 * * * tar -zcf /var/backups/home.tgz /home/ #每天上午6點做備份 52 06 * * * sudo reboot #每天上午6:52 分重新開機 ###03 07 * * * sudo iptables -A INPUT -p ICMP --icmp-type 8 -j DROP */5 * * * * sudo env LANG=C mrtg /etc/mrtg.cfg #每5分鐘執行mrtg crontab 每小時、每分鐘 寫法 crontab 每小時的寫法: 0 * * * * 說明:每小時的0分做什麼事。 crontab 每分鐘的寫法: */1 * * * * 說明:每隔1分鐘做什麼事。(1可更換成2、5、10、…) #################################################### tar -zcf /var/backups/home.tgz /home/ #################################################### openvpn log file /usr/local/vpnserver/server_log /usr/local/vpnserver/security_log #################################################### 在 Linux 用 iptables 封鎖 ip 在 Linux 下如果要封鎖 ip 的網路流量, 可以透過 iptables 實現, 指令如下: iptables -A INPUT -s IP_ADDRESS -j DROP iptables -A INPUT -d IP_ADDRESS -j DROP 只要將想封鎖的 ip 方法上面的 IP_ADDRESS 位置便可以了. sudo iptables -A INPUT -s 114.91.131.199 -j DROP sudo iptables -A INPUT -d 114.91.131.199 -j DROP 如果想刪除封鎖的話, 只要將上面 iptables 指令的 -A 改成 -D 便可以了, 例如: iptables -D INPUT -s IP_ADDRESS -j DROP 來自 192.168.1.25 的封包都給他丟棄去! [root@test root]# iptables -A INPUT -i eth0 -p tcp -s 192.168.1.25 -j DROP 有一種情況是不想將某個 ip 的全部流量封鎖, 只想封鎖指定的 port 埠號, 可以這樣做: iptables -A INPUT -s IP_ADDRESS -p tcp –destination-port 25 -j DROP 以上指令透過 iptables 的 –destination-port 選項, 指令只封鎖 port 25 的流量. 但如果只是簡單的輸入 iptables 封鎖 IP, 當主機 reboot 或者重新啟動 iptables 後, 所加入的規則便會全部刪除, 在 Redhat/Centos 下可以用以下指令將規則儲存到 config file 內: service iptables save 如果想刪除封鎖的話, 只要將上面 iptables 指令的 -A 改成 -D 便可以了, 例如: iptables -D INPUT -s IP_ADDRESS -j DROP https://wiki.debian.org/iptables #################################################### DD 教學 https://www.cyberciti.biz/faq/how-to-create-disk-image-on-mac-os-x-with-dd-command/ You can create compressed disk image as follows: $ sudo dd if=/dev/disk2 bs=64K | gzip -c > backup.disk.img.dd.gz #################################################### sudo apt-get dist-upgrade #################################################### #################################################### sudo apt-get install telnetd sudo /etc/init.d/openbsd-inetd restart #################################################### ps -ax | grep sshd and use kill -9 to kill the process. #################################################### vcgencmd measure_temp sudo nano /var/www/html/mrtg/61.63.1.157_2.log #################################################### list all user , cut -d: -f1 /etc/passwd #################################################### rm -rf .* * 如果LZ想删除文件夹的 可以 rm -rf dir 这样快点 #################################################### #################################################### #################################################### #################################################### #################################################### #################################################### sudo iptables -A INPUT -s 218.87.109.152 -j DROP sudo iptables -A INPUT -d 218.87.109.152 -j DROP hckao@server157:/etc $ cat rc.local #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. # Print the IP address _IP=$(hostname -I) || true if [ "$_IP" ]; then printf "My IP address is %s\n" "$_IP" fi ####sudo iptables -t nat -A POSTROUTING -s 172.18.100.0/24 -o eth0 -j SNAT --to 61.63.1.157 ##for pptp sudo iptables -t nat -A POSTROUTING -s 172.18.100.0/24 -o eth0 -j MASQUERADE ###disable icmp type 8 echo sudo iptables -A INPUT -p ICMP --icmp-type 8 -j DROP ###disable icmp type 8 echo sudo iptables -A INPUT -p ICMP --icmp-type 8 -j DROP ###disable ip 114.91.131.199 access l2tp service sudo iptables -A INPUT -s 114.91.131.199 -j DROP sudo iptables -A INPUT -d 114.91.131.199 -j DROP sudo iptables -A INPUT -s 58.37.201.139 -j DROP sudo iptables -A INPUT -d 58.37.201.139 -j DROP sudo iptables -A INPUT -s 218.1.157.160 -j DROP sudo iptables -A INPUT -d 218.1.157.160 -j DROP #sudo iptables -A INPUT -s 223.104.210.0/255.255.255.0 -j DROP #sudo iptables -A INPUT -d 223.104.210.0/255.255.255.0 -j DROP ###shutdown wlan0 sudo ifconfig wlan0 down #iptables-restore < /etc/iptables.ipv4.nat exit 0 hckao@server157:/etc $ *************************************************************************** 原版的dhcpcd.conf(未更改) pi@raspberrypi:/etc $ cat dhcpcd.conf # A sample configuration for dhcpcd. # See dhcpcd.conf(5) for details. # Allow users of this group to interact with dhcpcd via the control socket. #controlgroup wheel # Inform the DHCP server of our hostname for DDNS. hostname # Use the hardware address of the interface for the Client ID. clientid # or # Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361. # Some non-RFC compliant DHCP servers do not reply with this set. # In this case, comment out duid and enable clientid above. #duid # Persist interface configuration when dhcpcd exits. persistent # Rapid commit support. # Safe to enable by default because it requires the equivalent option set # on the server to actually work. option rapid_commit # A list of options to request from the DHCP server. option domain_name_servers, domain_name, domain_search, host_name option classless_static_routes # Most distributions have NTP support. option ntp_servers # Respect the network MTU. This is applied to DHCP routes. option interface_mtu # A ServerID is required by RFC2131. require dhcp_server_identifier # Generate Stable Private IPv6 Addresses instead of hardware based ones slaac private # Example static IP configuration: #interface eth0 #static ip_address=192.168.0.10/24 #static ip6_address=fd51:42f8:caae:d92e::ff/64 #static routers=192.168.0.1 #static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1 # It is possible to fall back to a static IP if DHCP fails: # define static profile #profile static_eth0 #static ip_address=192.168.1.23/24 #static routers=192.168.1.1 #static domain_name_servers=192.168.1.1 # fallback to static profile on eth0 #interface eth0 #fallback static_eth0 ******************************************************* sudo apt-get install pppoeconf ppp #安裝pppoeconf、ppp套件 等待安裝完成...等等等~ sudo pppoeconf ******************************************************* raspi-config set ssh set time set location install apache2 install mtr ******************************************************* hckao@ddns_net:~ $ cat easy iptables -X iptables -Z iptables -P INPUT DROP iptables -P OUTPUT ACCEPT iptables -P FORWARD ACCEPT /etc/init.d/service start /etc/init.d/service enable sudo shutdown -r now #################################################### vcgencmd measure_clock 其中的 是指定要查詢的硬體, 可用的選項有 arm、 core、 h264、 isp、 v3d、 uart、pwm、 emmc、 pixel、 vec、 hdmi、 dpi。 vcgencmd codec_enabled 其中 是指定要查詢的 codec,可用的選項有: H264、 MPG2、 WVC1、 MPG4、 MJPG、 WMV9。 vcgencmd measure_clock arm vcgencmd measure_volts vcgencmd measure_temp vcgencmd get_config int vcgencmd get_mem arm vcgencmd get_mem gpu vcgencmd version vcgencmd commands vcgencmd get_config int 如果要查看 vcgencmd 指令所有可用的參數,可以執行 vcgencmd commands #################################################### ####sudo mkdir /media/usb sudo chown -R pi:pi /media/usb sudo mount /dev/sda1 /media/usb -o uid=pi,gid=pi sudo chown -R hckao:hckao /media/usb sudo mount /dev/sda1 /media/usb -o uid=hckao,gid=hckao sudo umount /media/usb #################################################### root@raspberrypi:/usr/local/vpnserver# ./vpnserver start #; softether restart #################################################### pi@raspberrypi:~ $ lsb_release -a No LSB modules are available. Distributor ID: Raspbian Description: Raspbian GNU/Linux 8.0 (jessie) Release: 8.0 Codename: jessie pi@raspberrypi:~ $ ~$ sudo apt-get install lsb-core -y #################################################### sudo adduser sudo sudo userdel -r pi #################################################### sudo apt-get install pppoeconf ppp #安裝pppoeconf、ppp套件 等待安裝完成...等等等~ sudo pppoeconf #################################################### sudo service iptables status----------no data sudo iptables -L #################################################### hckao@ddns:~ $ lscpu Architecture: armv7l Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 1 Core(s) per socket: 4 Socket(s): 1 Model name: ARMv7 Processor rev 4 (v7l) CPU max MHz: 1200.0000 CPU min MHz: 600.0000 #################################################### sudo iptables -A INPUT -p ICMP --icmp-type 8 -j DROP iptables -A INPUT -i ppp0 -s 220.133.209.15 -j ACCEPT #允許指定IP連線 iptables -A INPUT -i ppp0F -s 220.134.245.198 -j ACCEPT #允許指定IP連線 iptables -A INPUT -i ppp0 -s 61.63.1.0/255.255.255.0 -j ACCEPT #允許指定IP連線 sudo iptables -F sudo iptables -X sudo iptables -Z sudo iptables -P INPUT DROP sudo iptables -P OUTPUT ACCEPT sudo iptables -P FORWARD ACCEPT #################################################### 目前的rc.local,兩條 ##for pptp sudo iptables -t nat -A POSTROUTING -s 172.18.100.0/24 -o eth0 -j MASQUERADE ##disable icmp type 8 echo sudo iptables -A INPUT -p ICMP --icmp-type 8 -j DROP #################################################### systemctl daemon-reload #################################################### sudo apt-get install sysstat sar -u 1 5 #################################################### VCHI initialization failed sudo usermod -aG video #################################################### service reload systemctl daemon-reload #################################################### DD 教學 https://www.cyberciti.biz/faq/how-to-create-disk-image-on-mac-os-x-with-dd-command/ You can create compressed disk image as follows: $ sudo dd if=/dev/disk2 bs=64K | gzip -c > backup.disk.img.dd.gz #################################################### apt-get dist-upgrade apt-get do-release-upgrade apt-get update 軟體資料庫同步:apt-get update 會根據 /etc/apt/sources.list 中設定到 APT Server 去更新軟體資料庫,在任何更新之前最好都先做這一個動作,讓軟體資料保持在最新的狀況之下。/etc/apt/sources.list 可以用 apt-setup 來設定。 apt-get install 軟體安裝:安裝軟體最怕的就是軟體間的相依、相斥關係,但是在 Debian 裡頭安裝軟體是一件非常愉悅的事情,只要 『 apt-get install 』一行指令簡簡單單輕輕鬆鬆即可完成,所有相依、相斥 Debian 都會幫我們自動解決,您只要回答 『 Y 』就可以。依照預設值,透過 sudo apt-get install 安裝軟體時,會將檔案暫存在 /var/cache/apt/archives/ 目錄裡 apt-get remove 軟體移除:與 install 一樣,Debian 一樣會幫您處理移除軟體時所發生的相依問題。apt-get –purge remove 則連設定檔也會移除。 apt-get autoremove 清除下載的暫存檔 apt-get source 如果您想取得某個軟體套件 ( packages ) 的原始碼可以透過這個指令達成。如果用apt-get source –compile pkg1,則是抓回 source pkg1並編譯成 binary pkg1, –compile 參數就如同 rpm -ba 一般 apt-get build-dep 為源碼配置所需的建構相依關係 apt-get upgrade 軟體升級:平常我們很難顧慮到系統上所安裝的數十甚至數百套軟體的版本是否有新版出現,現在只要下這個指令 Debian 便會自動找出所有有新版的軟體套件並逐一升級。 apt-get dist-upgrade 系統升級:當轉移整個系統時,如 『 stable 』 轉換到 『 testing 』,或是系統運行好一段時間都應該下這個指令,它會聰明的處理到很多軟體相依、相斥的問題。 apt-get dselect-upgrade 根據 dselect 的選擇來進行升級 apt-get clean 我們透過 apt-get 安裝的任何軟體都會先下載到 『 /var/cache/apt/archives/ 』及 『 /var/cache/apt/archive/partial/ 』 目錄底下,一般預設 apt-get 在安裝完軟體後是不會把上述位置底下的 『 .deb 』 殺除,一段時間後您如果覺得系統空間不足,您可以下 『 apt-get clean 』讓系統自動清理這個目錄。 apt-get autoclean 類似 『 apt-get clean 』,下此參數時 apt-get 在安裝完畢後會自動刪除該軟體的 『 .deb 』 檔。 apt-get check apt-get 不是萬能,有時候也是會出現問題,遇到有問題的時候您可以下 『 apt-get check 』來診斷問題所在。 #################################################### sudo apt-get install telnetd sudo /etc/init.d/openbsd-inetd restart #################################################### #################################################### vcgencmd measure_clock arm vcgencmd measure_volts vcgencmd measure_temp vcgencmd get_config int vcgencmd get_mem arm vcgencmd get_mem gpu vcgencmd version vcgencmd commands vcgencmd get_config int #################################################### #################################################### ps -ax | grep sshd and use kill -9 to kill the process. #################################################### ethtool eth0 | grep -i speed ******************************************************* ******************************************************* ******************************************************* ******************************************************* ------一些指令------ ethtool eth0 | grep -i speed du -h 可知目前此資料夾下所有檔案與資料夾所佔硬碟大小總數 du -s 可知目前此資料夾總共佔用硬碟大小總數,以G為單位 du -sh 可知目前此資料夾總共佔用硬碟大小總數,以G為單位 ---------------------------------- 於2020-08-20有修改,把dns改為中華跟和網 /etc/ppp/options.xl2tpd 有備份原始檔案 /etc/ppp/options.xl2tpd.org 重新開機時間是 59分40秒 ----------------------------------