RaspBain教學 ADATA 32G MicroSD pi@hckao.ddns.net giga1144 pi@192.168.1.201 giga1144 pi@172.24.1.1 gigia1144 img file 路徑 一些單獨的指令 /etc/init.d/service start /etc/init.d/service enable service --status-all sudo raspi-config root@raspberrypi:/usr/local/vpnserver# ./vpnserver start softether啟動 nano /etc/apt/sources.list deb http://ftp.us.debian.org/debian/ wheezy main contrib non-free deb-src http://ftp.us.debian.org/debian/ wheezy main contrib non-free deb http://security.debian.org/ wheezy/updates main contrib non-free deb-src http://security.debian.org/ wheezy/updates main contrib non-free # wheezy-updates, previously known as 'volatile' deb http://ftp.us.debian.org/debian/ wheezy-updates main contrib non-free deb-src http://ftp.us.debian.org/debian/ wheezy-updates main contrib non-free deb http://download.webmin.com/download/repository sarge contrib deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib sudo shutdown -r now vcgencmd measure_temp https://blog.gtwang.org/iot/raspberry-pi-vcgencmd-hardware-information/ ********************************* 設定固定ip pi@raspberrypi:/etc $ nano dhcpcd.conf interface eth0 static ip_address=192.168.1.202 static routers=192.168.1.1 static domain_name_servers=8.8.8.8 static domain_search= ********************************* mount usb pi@raspberrypi:/media $ sudo mkdir /media/usb pi@raspberrypi:/media $ sudo chown -R pi:pi /media/usb pi@raspberrypi:/media $ sudo mount /dev/sda1 /media/usb -o uid=pi,gid=pi pi@raspberrypi:/media $ sudo mkdir /media/usb sudo chown -R pi:pi /media/usb sudo mount /dev/sda1 /media/usb -o uid=pi,gid=pi sudo umount /media/usb ********************************* sudo adduser sudo pi@raspberrypi:~ $ lsb_release -a ******************************************************* pppoe 設定 http://thinker-evans.blogspot.tw/2015/04/raspberry-pi-adsl-pppoe.html $ sudo apt-get install pppoeconf ppp #安裝pppoeconf、ppp套件 等待安裝完成...等等等~ sudo pppoeconf 幾本操作: 撥接連線 $ sudo pon dsl-provider 中斷連線 $ sudo poff 查詢連線紀錄 $ plog 查詢網路組態 $ ifconfig #列出所有的網路組態 $ ifconfig ppp0 #只列出ppp0的網路組態 修改資料: 1.「軟體修改」連線資訊ISP帳號、密碼、自動連線...等,再執行一次 $ sudo pppoeconf #將流程再跑一遍 Uninstall just pppoe sudo apt-get remove pppoe This will remove just the pppoe package itself. Uninstall pppoe and its dependencies sudo apt-get remove --auto-remove pppoe Purging your config/data too If you also want to delete your local/config files for pppoe then this will work. Caution! Purged config/data can not be restored by reinstalling the package. sudo apt-get purge pppoe Or similarly, like this pppoe sudo apt-get purge --auto-remove pppoe ******************************************************* FTP SERVER http://www.htpcguides.com/install-configure-ftp-server-debian-linux-raspberry-pi/ sudo apt-get install vsftpd sudo nano /etc/vsftpd.conf remove "#" at line local enable =yes remove "#" at line write enable =yes On Linux hidden files are preceded with a ‘.’ if you want to be able to see hidden folders, add this line at the bottom force_dot_files=YES sudo service vsftpd restart /etc/init.d/vsftpd start ******************************************************* BT Torrent https://pimylifeup.com/raspberry-pi-torrentbox/ http://www.techjawab.com/2014/08/how-to-install-transmission-on.html 以下是下載的目錄 /var/lib/transmission-daemon/Downloads 1. Firstly let’s bring the Pi up to date to avoid any potential issues installing the torrent client. 2. sudo apt-get update sudo apt-get upgrade 3. Firstly, lets download and install transmission by using the following command sudo apt-get install transmission-daemon 3. If you plan on storing on an external drive for example a USB hard drive then we need to make directories for the torrents to stored. (NASHDD1 is the hard drive I mounted in the NAS tutorial) 4. sudo mkdir -p /media/pi/T32G/download sudo mkdir -p /media/pi/T32G/temp 5. Now we will need to make a few changes to the transmission settings file, enter the following command: sudo nano /etc/transmission-daemon/settings.json 5. I recommended making the following changes but there are other settings you may want to update depending on your preference. If you want information all the settings you can change then check out transmissions website here. 6. "incomplete-dir": "/media/pi/T32G/torrent-inprogress", "incomplete-dir-enabled": true, 7. "download-dir": "/media/pi/T32G/torrent_complete", "rpc-password": "Your_Password", 8. "rpc-username": "Your_Username", "rpc-whitelist": "192.168.1.*,172.24.1.*,172.18.100.*", 9. Now reload transmission, if you restart your changes to the config file will be lost. You can reload the service by entering the following command. sudo service transmission-daemon reload 10. If you didn’t change the location of the download directories you can skip to step 17, otherwise complete the next few steps. 11. We will also need to update a few more places to make sure that transmission runs as the correct user, if we don’t we will run into lots of errors. First lets stop the transmission service by entering the following command: sudo service transmission-daemon stop 12. Now we need to edit the daemon so it launches as the user who owns the directory we wish to store in (To check who owns the folder use ls -l /your_directory/download_dir), first open the file by entering the following command. sudo nano /etc/init.d/transmission-daemon 13. In here edit the user so it runs as the user who owns the directory we’re storing our downloads in. In my case it is pimylifeup instead of debian-transmission. We need do this because the folder we are going to store our torrents are likely to be owned by a different user to the default transmission. To see who owns the directories use ls -l in the folder that contains the download folders. (Update pimylifeup with the relevant username) USER=pimylifeup 14. We also need to chown some files since we are no longer using the debian-transmission user. If you don’t do this you errors and transmission will fail to launch. (Make sure you update pimylifeup with the username you’re using) 15. sudo chown -R pimylifeup:pimylifeup /etc/transmission-daemon 16. sudo chown -R pimylifeup:pimylifeup /etc/init.d/transmission-daemon sudo chown -R pimylifeup:pimylifeup /var/lib/transmission-daemon 17. We also need to change the user in the following file. Failing to do will result in an error when go to relaunch the service. sudo nano /etc/systemd/system/multi-user.target.wants/transmission-daemon.service 18. In here change the user to the relevant user, in my case it is pimylifeup. user=pimylifeup 19. Now reload the systemctl file by entering the following: sudo systemctl daemon-reload 20. Next we need to create the directory where the setting.json file will be accessed by the transmission-daemon. We then need to create a symbolic link (ln) back to the settings file we edited earlier, update pimylifeup with the relevant username. (If don’t don’t do this then transmission will create a default file in it’s place) 21. sudo mkdir -p /home/pimylifeup/.config/transmission-daemon/ 22. sudo ln -s /etc/transmission-daemon/settings.json /home/pimylifeup/.config/transmission-daemon/ sudo chown -R pimylifeup:pimylifeup /home/pimylifeup/.config/transmission-daemon/ 23. Let's start the transmission service back up by entering the following. sudo service transmission-daemon start 24. Now you can check out your torrent box by opening it up in a web browser. If you haven't got your Pi's IP simply use the command hostname -I on the Pi. Enter the following URL to get to the interface. (Change the your_pi_ip with your Raspberry Pi’s IP) http://your_pi_ip:9091 25. In here you can add & remove torrents, change settings, set schedules and much more. If you need more information on all these settings be sure to hit up transmissions website here. 26. ******************************************************* openmediavault.org http://wiki.openmediavault.org/index.php?title=1.0/Installation_Apt-Get#Initialize_OpenMediaVault ******************************************************* SAMBA https://www.stewright.me/2013/05/turn-a-raspberry-pi-into-a-nas-network-attached-storage-server/ http://www.howtogeek.com/139433/how-to-turn-a-raspberry-pi-into-a-low-power-network-storage-device/ ******************************************************* 無線AP設定 https://frillip.com/using-your-raspberry-pi-3-as-a-wifi-access-point-with-hostapd/ PACKAGES sudo apt-get install dnsmasq hostapd CONFIGURE YOUR INTERFACES 1 sudo nano /etc/dhcpcd.conf denyinterfaces wlan0 Note: This must be ABOVE any interface lines you may have added! 2 sudo nano /etc/network/interfaces and edit the wlan0section so that it looks like this: allow-hotplug wlan0 iface wlan0 inet static address 172.24.1.1 netmask 255.255.255.0 network 172.24.1.0 broadcast 172.24.1.255 # wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf Restart dhcpcd with sudo service dhcpcd restart and then reload the configuration for wlan0 with sudo ifdown wlan0; sudo ifup wlan0. 3 CONFIGURE HOSTAPD Next, we need to configure hostapd. Create a new configuration file with sudo nano /etc/hostapd/hostapd.conf with the following contents: # This is the name of the WiFi interface we configured above interface=wlan0 # Use the nl80211 driver with the brcmfmac driver driver=nl80211 # This is the name of the network ssid=Pi3-AP # Use the 2.4GHz band hw_mode=g # Use channel 6 channel=6 # Enable 802.11n ieee80211n=1 # Enable WMM wmm_enabled=1 # Enable 40MHz channels with 20ns guard interval ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40] # Accept all MAC addresses macaddr_acl=0 # Use WPA authentication auth_algs=1 # Require clients to know the network name ignore_broadcast_ssid=0 # Use WPA2 wpa=2 # Use a pre-shared key wpa_key_mgmt=WPA-PSK # The network passphrase wpa_passphrase=0937519607 # Use AES, instead of TKIP rsn_pairwise=CCMP We can check if it's working at this stage by running sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf. If it's all gone well thus far, you should be able to see to the network Pi3-AP! If you try connecting to it, you will see some output from the Pi, but you won't receive and IP address until we set up dnsmasq in the next step. Use Ctrl+C to stop it. We aren't quite done yet, because we also need to tell hostapd where to look for the config file when it starts up on boot. Open up the default configuration file with sudo nano /etc/default/hostapd and find the line #DAEMON_CONF="" and replace it with DAEMON_CONF="/etc/hostapd/hostapd.conf”. 檢查log sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf ——檢查log 4 CONFIGURE DNSMASQ The shipped dnsmasq config file contains a wealth of information on how to use it, but the majority of it is largely redundant for our purposes. I'd advise moving it (rather than deleting it), and creating a new one with sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig sudo nano /etc/dnsmasq.conf Paste the following into the new file: interface=wlan0 # Use interface wlan0 listen-address=172.24.1.1 # Explicitly specify the address to listen on bind-interfaces # Bind to the interface to make sure we aren't sending things elsewhere server=8.8.8.8 # Forward DNS requests to Google DNS domain-needed # Don't forward short names bogus-priv # Never forward addresses in the non-routed address spaces. dhcp-range=172.24.1.50,172.24.1.150,12h # Assign IP addresses between 172.24.1.50 and 172.24.1.150 with a 12 hour lease time 5 SET UP IPV4 FORWARDING One of the last things that we need to do before we send traffic anywhere is to enable packet forwarding. To do this, open up the sysctl.conf file with sudo nano /etc/sysctl.conf, and remove the # from the beginning of the line containing net.ipv4.ip_forward=1. This will enable it on the next reboot, but because we are impatient, activate it immediately with : sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward" We also need to share our Pi's internet connection to our devices connected over WiFi by the configuring a NAT between our wlan0 interface and our eth0interface. We can do this using the following commands: sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT # Wireless AP 用 sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE sudo iptables -A FORWARD -i ppp0 -o wlan0 -m state --state RELATED,ESTABLISHED $ sudo iptables -A FORWARD -i wlan0 -o ppp0 -j ACCEPT However, we need these rules to be applied every time we reboot the Pi, so run sudo sh -c "iptables-save > /etc/iptables.ipv4.nat” to save the rules to the file /etc/iptables.ipv4.nat. Now we need to run this after each reboot, so open the rc.local file with sudo nano /etc/rc.local and just above the line exit 0, add the following line: sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT iptables-restore < /etc/iptables.ipv4.nat exit 0 ******************************************************* SETTING UP AN APACHE WEB SERVER ON A RASPBERRY PI https://www.raspberrypi.org/documentation/remote-access/web-server/apache.md ******************************************************* 中文安裝 https://blog.gtwang.org/iot/raspberry-pi-chinese-input-method/ ******************************************************* DDNS NOIP.com 設定 karl_kao@yahoo.com / giga1144 hckaopi3.ddns.net https://www.youtube.com/watch?v=8xp4kkbsZi0&feature=youtu.be http://projpi.com/raspberry-pi-tips-and-hacks/raspberry-pi-2-on-dynamic-ip-and-noip/ http://unix.stackexchange.com/questions/199178/run-automatically-noip2-when-the-machine-is-booted To install the DUC on the Raspberry Pi, Enter the following commands at the terminal : 1. “sudo mkdir /home/pi/noip ” ( Create a folder for noip’s DUC) 2. “cd /home/pi/noip” (Change working folder to the new folder just created) 3. “sudo wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz” (Download the Software) 4. “sudo tar vzxf noip-duc-linux.tar.gz” (Extract the downloaded software) 5. “ls” (to show the newly folder created by extracting the archive) 6. “cd noip-2.1.9-1” (Change working directory to noip-2.1.9-1 or what ever is the newly created folder by the step above) You will now need to compile and install the downloaded DUC by entering : 1. sudo make 2. sudo make install (during the install process you will need to enter your email and password that you created at noip.com) the Dynamic Update client is started by running “sudo /usr/local/bin/noip2” . The DUC service will now run until the Pi is shutdown. To make the DUC startup automatically and run in the back ground, We will need write a small script that will execute at startup. “sudo nano /etc/init.d/noipscript” (use nano the word editor to create a file called noipscript) Enter the following lines into nano : #! /bin/sh ### BEGIN INIT INFO # Provides: noip2 # Required-Start: $syslog # Required-Stop: $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: noip.com client service ### END INIT INFO # . /lib/lsb/init-functions case "$1" in start) echo "Starting noip2." /usr/local/bin/noip2 ;; stop) echo "Shutting down noip2." killall noip2 #killproc /usr/local/bin/noip2 ;; *) echo "Usage: $0 {start|stop}" exit 1 esac exit 0 To exit nano, press ctrl+x and Y to save changes to the file. We will now need to make the script executable by changing its permissions and update the rc.d scripts by entering : sudo chmod +x /etc/init.d/noipscript sudo update-rc.d noipscript defaults ---------------------------- sudo crontab -e (choose your favorite text editor if prompted) Add this line at the bottom of the file... @reboot su -l && sudo noip2 Now the Dynamic Update Client of No-ip should start everytime your Pi starts up and update your IP address. You will need to configure your Home Router to port forward the relevant port to your PI. i.e., If you are hosting a website, you will want to forward Port 80 and Port 443 to the IP address of the Pi. 路徑 pi@raspberrypi:/usr/local/etc $ sudo cat no-ip2.conf pi@raspberrypi:/usr/local/bin $ ls noip2 pi@raspberrypi:/usr/local/bin $ sudo noip2 -S 1 noip2 process active. Process 485, started as noip2, (version 2.1.9) Using configuration from /usr/local/etc/no-ip2.conf Last IP Address set 1.160.32.131 Account karl_kao@yahoo.com configured for: host hckaopi3.ddns.net Executing username=karl_kao%40yahoo.com&pass=giga1144&h[]=hckaopi3.ddns.net upon successful update. Updating every 30 minutes via /dev/eth0 with NAT enabled. ******************************************************* pptp server設定 http://raspberrypihelp.net/raspberry-pi-pptp-vpn-server/ https://www.linuxbabe.com/linux-server/setup-your-own-pptp-vpn-server-on-debian-ubuntu-centos sudo nano /etc/rc.local #sudo iptables -t nat -A POSTROUTING -s 192.168.0.234/24 -o eth0 -j SNAT --to IPADRESOFYOURRASPBERRYPI sudo iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE 目前是用以下 # pptp用 sudo iptables -t nat -A POSTROUTING -s 172.18.100.0/24 -o ppp0 -j MASQUERADE sudo iptables -A INPUT -p tcp --dport 47 -j ACCEPT sudo iptables -A INPUT -p gre -j ACCEPT # Wireless AP 用 sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE sudo iptables -A FORWARD -i ppp0 -o wlan0 -m state --state RELATED,ESTABLISHED $ sudo iptables -A FORWARD -i wlan0 -o ppp0 -j ACCEPT iptables-restore < /etc/iptables.ipv4.nat exit 0 If you have Systemd on your server, then enable pptpd service on system boot: sudo systemctl enable pptpd 以下是自動啟動 sudo ln -s /etc/init.d/pptpd /etc/rc2.d/S16pptpd sudo systemctl enable pptpd ******************************************************* L2TP Server https://gist.github.com/jhenkens/11190151 ******************************************************* Configure and Install Webmin nano /etc/apt/sources.list (Use nano text editor to edit sources.list file located in the /etc/apt folder) deb http://download.webmin.com/download/repository sarge contrib deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib Next, step is to fetch and install the Webmin GPG key with which the repository is signed, with the commands : cd /root wget http://www.webmin.com/jcameron-key.asc apt-key add jcameron-key.asc The Pi is now read to Install Webmin. Enter the following commands : apt-get update apt-get install webmin Webmin 預設使用 10000 埠號, 設定 firewall 開通 10000 埠號: ufw allow 10000 ******************************************** MRTG 重新啟動 root@raspberrypi:/etc/init.d# mrtg Daemonizing MRTG ... root@raspberrypi:/etc/init.d# mrtg restart http://www.supagusti.tk/computer/raspberrypi/160-installing-mrtg-on-your-pi http://tonyhack.familyds.net/wordpress/?p=4176 http://www.supagusti.tk/computer/raspberrypi/160-installing-mrtg-on-your-pi http://blog.itist.tw/2014/05/mrtg.html http://resources.intenseschool.com/network-monitoring-with-mrtg-on-raspberry-pi/ https://www.dd-wrt.com/wiki/index.php/SNMP https://wiki.openwrt.org/doc/howto/snmp.server 220.134.245.198—新店IP mrtg 路徑 /var/www/html/mrtg 安裝步驟 su apt-get install mtg Creating a configuration file for a device using cfgmaker giga1144@hckao.ddns.net >> /etc/mrtg.cfg indexmaker /etc/mrtg.cfg > /var/www/html/mrtg/index.html Make mrtg to run as a daemon: Edit the /etc/mrtg.cfg and add the line “RunAsDaemon: YES” (see line 9 below) 1: ###################################################################### 2: # Multi Router Traffic Grapher -- Sample Configuration File 3: ###################################################################### 4: # This file is for use with mrtg-2.5.4c 5: 6: # Global configuration 7: WorkDir: /var/www/mrtg 8: WriteExpires: Yes 9: RunAsDaemon: Yes Save and quit your editor and then create a file within the /etc/init.d directory and insert the following content: 1: PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 2: DAEMON="/usr/bin/mrtg" 3: PARAM=" --user=root /etc/mrtg.cfg --logging /var/log/mrtg.log" 4: NAME="MRTG" 5: DESC="Multi Router Traffic Grapher Daemon" 6: 7: test -f $DAEMON || exit 0 8: 9: set -e 10: 11: case "$1" in 12: start) 13: echo -n "Starting $DESC: " 14: env LANG=C $DAEMON $PARAM 15: echo "$NAME." 16: ;; 17: stop) 18: echo -n "Stopping $DESC: " 19: killall -9 mrtg 20: echo "$NAME." 21: ;; 22: restart|force-reload) 23: echo -n "Restarting $DESC: " 24: killall -9 mrtg 25: sleep 1 26: env LANG=C $DAEMON $PARAM 27: echo "$NAME." 28: ;; 29: *) 30: N=/etc/init.d/$NAME 31: echo "Usage: $N {start|stop|restart|force-reload}" >;&2 32: exit 1 33: ;; 34: esac 35: 36: exit 0 update-rc.d mrtg defaults --------------------------------------------------------------------------------------------- PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON="/usr/bin/mrtg" PARAM=" --user=root /etc/mrtg.cfg --logging /var/log/mrtg.log" NAME="MRTG" DESC="Multi Router Traffic Grapher Daemon" test -f $DAEMON || exit 0 set -e case "$1" in start) echo -n "Starting $DESC: " env LANG=C $DAEMON $PARAM echo "$NAME." ;; stop) echo -n "Stopping $DESC: " killall -9 mrtg echo "$NAME." ;; restart|force-reload) echo -n "Restarting $DESC: " killall -9 mrtg sleep 1 env LANG=C $DAEMON $PARAM echo "$NAME." ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|force-reload}" >;&2 exit 1 ;; esac exit 0 --------------------------------------------------------------------------------------------- 重新啟動 root@raspberrypi:/etc/init.d# mrtg Daemonizing MRTG ... root@raspberrypi:/etc/init.d# mrtg restart root@raspberrypi:/etc# LANG=C /usr/bin/mrtg Daemonizing MRTG ... root@raspberrypi:/etc# cfgmaker 9a1782@220.134.245.198 >> /etc/mrtg.cfg indexmaker /etc/mrtg.cfg > /var/www/html/mrtg/index.html ****************************************************** 產生一個mttg設定檔 1 sudo cfgmaker --output /etc/mrtg.cfg public@localhost 修改設定檔 1 vim /etc/mrtg.cfg WorkDir: /var/www/mrtg #請修改成你的網頁目錄路徑 建立網頁目錄 1 sudo mkdir /var/www/mrtg 產生 MRTG 的首頁 1 sudo indexmaker --output=/var/www/html/mrtg/index.html /etc/mrtg.cfg 產生 MRTG 資料,至少執行三次 1 sudo env LANG=C mrtg /etc/mrtg.cfg 編輯 cron 系統排程設定檔 每5分執行一次 # mrtg */5 * * * * sudo env LANG=C mrtg /etc/mrtg.cfg 等待5-10分後開啟網頁http://yourip/mrtg/ Creating a configuration file for a device using #cfgmaker public@192.168.0.1 >> /etc/mrtg.cfg hckao@server157:~ $ cat mrtg 產生一個mttg設定檔 1 sudo cfgmaker --output /etc/mrtg.cfg public@localhost 修改設定檔 1 vim /etc/mrtg.cfg WorkDir: /var/www/html/mrtg #請修改成你的網頁目錄路徑 建立網頁目錄 1 sudo mkdir /var/www/mrtg 產生 MRTG 的首頁 1 sudo indexmaker --output=/var/www/html/mrtg/index.html /etc/mrtg.cfg 產生 MRTG 資料,至少執行三次 1 sudo env LANG=C mrtg /etc/mrtg.cfg 編輯 cron 系統排程設定檔 每5分執行一次 Creating a configuration file for a device using #cfgmaker public@192.168.0.1 >> /etc/mrtg.cfg indexmaker /etc/mrtg.cfg > /var/www/html/mrtg/index.html ****************************************************** CPU LOADING 1.sudo apt-get install sysstat 2.vim /etc/default/sysstat Find the line ENABLED="False" Change that to. ENABLED="true" Now let's restart the service and watch the logs grow. /etc/init.d/sysstat restart 3.iostat –c 重點說完了!再來說說 sar 吧!基本上, sar 可以用來偵測很多的咚咚,例如: • sar -u 1 5 :每一秒鐘測一次 cpu ,共計五次後算平均; • sar -r 3 3:每三秒看一次實體與虛擬記憶體用量,三次後算平均! • 其他的功能有待你的發掘囉! sudo cfgmaker --output /etc/mrtg.cfg public@localhost 修改設定檔 1 vim /etc/mrtg.cfg WorkDir: /var/www/mrtg #請修改成你的網頁目錄路徑 建立網頁目錄 1 sudo mkdir /var/www/mrtg 產生 MRTG 的首頁 1 sudo indexmaker --output=/var/www/mrtg/index.html /etc/mrtg.cfg 產生 MRTG 資料,至少執行三次 1 sudo env LANG=C mrtg /etc/mrtg.cfg ****************************************************** KODI https://www.linuxbabe.com/desktop-linux/install-kodi-debian-8-ubuntu pi@raspberrypi:~/noip/noip-2.1.9-1 $ cat README.FIRST This file describes noip2, a second-generation Linux client for the no-ip.com dynamic DNS service. NEW: This code will build and run on Solaris/Intel and BSD also. Edit the Makefile for Solaris and the various BSDs. For BSD users wanting to use a tun interface, see below. Let me know about any other changes needed for noip2 to operate correctly on your non-Linux OS. Mac OS X is a BSD variant. Please read this short file before using noip2. ########################################################################### HOW TO BUILD AN EXECUTABLE FOR YOUR SYSTEM The command make will build a binary of the noip2 client that will run on your system. If you do not have 'make' installed and you have an i686 Linux machine with libc6, a binary for i686 systems is located in the binaries directory called noip2-Linux. Copy that binary to the build directory 'cp binaries/noip2-Linux noip2' The command make install (which must be run as root) will install the various pieces to their appropriate places. This will ask questions and build a configuration data file. See below if you can't become root or can't write in /usr/local/*. ########################################################################### HOW TO USE THE CLIENT WITHOUT READING THE REST OF THIS TEXT Usual operation? /usr/local/bin/noip2 -C configure a client /usr/local/bin/noip2 run a client /usr/local/bin/noip2 -S display info about running clients /usr/local/bin/noip2 -D pid toggle the debug state for client pid /usr/local/bin/noip2 -K pid terminate client pid Have more than one internet access device? /usr/local/bin/noip2 -M -c file start additional instances ########################################################################### HOW TO START THE CLIENT The noip2 executable can be run by typing /usr/local/bin/noip2 If you want it to run automatically when the machine is booted, then place the following script in your startup directory. (/etc/init.d/rcX.d or /sbin/init.d/rcX.d or ???) ####################################################### #! /bin/sh # . /etc/rc.d/init.d/functions # uncomment/modify for your killproc case "$1" in start) echo "Starting noip2." /usr/local/bin/noip2 ;; stop) echo -n "Shutting down noip2." killproc -TERM /usr/local/bin/noip2 ;; *) echo "Usage: $0 {start|stop}" exit 1 esac exit 0 ####################################################### Where the 'X' in rcX.d is the value obtained by running the following command grep initdefault /etc/inittab | awk -F: '{print $2}' Killproc can be downloaded from ftp://ftp.suse.com/pub/projects/init Alternatively, you can uncomment the line after #! /bin/sh If you have a recent RedHat version, you may want to use the startup script supplied by another user. It's in this package called redhat.noip.sh It may need some modification for your system. There is a startup script for Debian called debian.noip2.sh. It also has been supplied by another user and is rumored to fail in some situations. Another user has supplied a proceedure to follow for MAc OS X auto startup. It's called mac.osx.startup. Mac users may wish to read that file. Here is a script which will kill all running copies of noip2. #!/bin/sh for i in `noip2 -S 2>&1 | grep Process | awk '{print $2}' | tr -d ','` do noip2 -K $i done These four lines can replace 'killproc' and 'stop_daemon' in the other scripts. If you are behind a firewall, you will need to allow port 8245 (TCP) through in both directions. ####################################################################### IMPORTANT!! Please set the permissions correctly on your executable. If you start noip2 using one of the above methods, do the following: chmod 700 /usr/local/bin/noip2 chown root:root /usr/local/bin/noip2 If you start noip2 manually from a non-root account, do the chmod 700 as above but chown the executable to the owner:group of the non-root account, and you will need to substitute your new path if the executable is not in /usr/local/bin. ########################################################################### SAVED STATE Noip2 will save the last IP address that was set at no-ip.com when it ends. This setting will be read back in the next time noip2 is started. The configuration data file must be writable for this to happen! Nothing happens if it isn't, the starting 0.0.0.0 address is left unchanged. If noip2 is started as root it will change to user 'nobody', group 'nobody'. Therefore the file must be writeable by user 'nobody' or group 'nobody' in this case! ########################################################################### BSD USING A TUN DEVICE Recent BSD systems will use getifaddrs() to list ALL interfaces. Set the 'bsd_wth_getifaddrs' define in the Makefile if using a version of BSD which supports getifaddrs() and ignore the rest of this paragraph. Mac OS X users should have a versdion of BSD which supports getifaddrs(). Otherwise set the 'bsd' define. The 'bsd' setting will not list the tun devices in BSD. Therefore a tun device cannot be selected from the menu. If you want to use a tun device you will need to edit the Makefile and change the line ${BINDIR}/${TGT} -C -Y -c /tmp/no-ip2.conf to ${BINDIR}/${TGT} -C -Y -c /tmp/no-ip2.conf -I 'your tun device' ########################################################################### COMMAND LINE ARGUMENTS WHEN INVOKING THE CLIENT The client will put itself in the background and run as a daemon. This means if you invoke it multiple times, and supply the multiple-use flag, you will have multiple instances running. If you want the client to run once and exit, supply the '-i IPaddress' argument. The client will behave well if left active all the time even on intermittent dialup connections; it uses very few resources. The actions of the client are controlled by a configuration data file. It is usually located in /usr/local/etc/no-ip2.conf, but may be placed anywhere if the '-c new_location' parameter is passed on the startup line. The configuration data file can be generated with the '-C' parameter. There are some new command line arguments dealing with default values in the configuration data file. They are -F, -Y and -U. The interval between successive testing for a changed IP address is controlled the '-U nn' parameter. The number is minutes, a minimum of 1 is enforced by the client when running on the firewall machine, 5 when running behind a router/firewall. A usual value for clients behind a firewall is 30. One day is 1440, one week is 10080, one month is 40320, 41760, 43200 or 44640. One hour is left as an exercise for the reader :-) The configuration builder code will allow selection among the hosts/groups registered at no-ip.com for the selected user. The '-Y' parameter will cause all the hosts/groups to be selected for update. Some sites have multiple connections to the internet. These sites confuse the auto NAT detection. The '-F' parameter will force the non-NAT or "firewall" setting. The client can be invoked with the '-i IPaddress' parameter which will force the setting of that address at no-ip.com. The client will run once and exit. The -I parameter can be used to override the device name in the configuration data file or to force the supplied name into the configuration data file while it is being created. Please use this as a last resort! The '-S' parameter is used to display the data associated with any running copies of noip2. If nothing is running, it will display the contents of the configuration data file that is selected. It will then exit. The '-K process_ID' parameter is used to terminate a running copy of noip2. The process_ID value can be obtained by running noip2 -S. The '-M' parameter will permit multiple running copies of the noip2 client. Each must have it's own configuration file. Up to 4 copies may run simultaneously. All errors and informational messages are stored via the syslog facility. A line indicating a successful address change at no-ip.com is always written to the syslog. The syslog is usually /var/log/messages. If the client has been built with debugging enabled, the usual state, the '-d' parameter will activate the debug output. This will produce a trace of the running program and should help if you are having problems getting the connection to no-ip.com established. All errors, messages and I/O in both directions will be displayed on the stderr instead of syslog. The additional '-D pid' parameter will toggle the debug state of a running noip2 process. This will not change where the output of the process is appearing; if it was going to the syslog, it will still be going to the syslog. One final invocation parameter is '-h'. This displays the help screen as shown below and ends. USAGE: noip2 [ -C [ -F][ -Y][ -U #min]][ -c file] [ -d][ -D pid][ -i addr][ -S][ -M][ -h] Version Linux-2.x.x Options: -C create configuration data -F force NAT off -Y select all hosts/groups -U minutes set update interval -c config_file use alternate data path -d increase debug verbosity -D processID toggle debug flag for PID -i IPaddress use supplied address -I interface use supplied interface -S show configuration data -M permit multiple instances -K processID terminate instance PID -h help (this text) ########################################################################### HOW TO CONFIGURE THE CLIENT The command noip2 -C will create configuration data in the /usr/local/etc directory. It will be stored in a file called no-ip2.conf. If you can't write in /usr/local/*, or are unable to become root on the machine on which you wish to run noip2, you will need to include the '-c config_file_name' on every invocation of the client, including the creation of the datafile. Also, you will probably need to put the executable somewhere you can write to. Change the PREFIX= line in the Makefile to your new path and re-run make install to avoid these problems. You will need to re-create the datafile whenever your account or password changes or when you add or delete hosts and/or groups at www.no-ip.com Each invocation of noip2 with '-C' will destroy the previous datafile. Other options that can be used here include '-F' '-Y' -U' You will be asked if you want to run a program/script upon successful update at no-ip.com. If you specify a script, it should start with #!/bin/sh or your shell of choice. If it doesn't, you will get the 'Exec format error' error. The IP address that has just been set successfully will be delivered as the first argument to the script/program. The host/group name will be delivered as the second argument. Some machines have multiple network connections. In this case, you will be prompted to select the device which connects to outside world. The -I flag can be supplied to select an interface which is not shown. Typically, this would be one of the pppx interfaces which do not exist until they are active. The code will prompt for the username/email used as an account identifier at no-ip.com. It will also prompt for the password for that account. The configuration data contains no user-serviceable parts!! IMPORTANT!! Please set the permissions correctly on the configuration data. chmod 600 /usr/local/etc/no-ip2.conf. chown root:root /usr/local/etc/no-ip2.conf. If you start noip2 manually from a non-root account, do the chmod as above but chown the no-ip2.conf file to the owner:group of the non-root account. Make sure the directory is readable! The program will drop root privileges after acquiring the configuration data file. ########################################################################### I would like to see this README.FIRST text translated to other languages. If you can convert this file from English to another language, please send the translated file to me. Thank you. ########################################################################### Bugs should be reported to johna@onevista.com Email me if you need help, but be aware I have extensive spam filtering. If your mailserver is blocked, send your message thru no-ip support. Don't send mail in html; no one will see it. You can make a trace file and examine it for error messages. Here's how to do that. Type: script noip2.out Type: 'your noip command line with the -d parameter added' Type: exit Examine the file noip2.out. Send it to me if you're still puzzled. johna@onevista.com January 2004 路徑 pi@raspberrypi:/usr/local/etc $ sudo cat no-ip2.conf pi@raspberrypi:/usr/local/bin $ ls noip2 pi@raspberrypi:/usr/local/bin $ sudo noip2 -S 1 noip2 process active. Process 485, started as noip2, (version 2.1.9) Using configuration from /usr/local/etc/no-ip2.conf Last IP Address set 1.160.32.131 Account karl_kao@yahoo.com configured for: host hckaopi3.ddns.net Executing username=karl_kao%40yahoo.com&pass=giga1144&h[]=hckaopi3.ddns.net upon successful update. Updating every 30 minutes via /dev/eth0 with NAT enabled. ****************************************************** ROUTE指令 Display default route Following three-command display the current routing table: # route Output: Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.0 * 255.255.255.0 U 0 0 0 ra0 default dsl-router 0.0.0.0 UG 0 0 0 ra0 OR $ /sbin/route Output: Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 191.255.255.0 * 255.255.255.0 U 0 0 0 eth0 169.254.0.0 * 255.255.0.0 U 0 0 0 eth0 default 191.255.255.1 0.0.0.0 UG 0 0 0 eth0 You can use -n option, to display numerical addresses instead of trying to determine symbolic host names (via dns or /etc/hosts file). This is useful if you are trying to determine why the route to your nameserver has vanished. $ /sbin/route -nOutput: Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 191.255.255.0 0.0.0.0 255.255.255.0 U 0 0 0 venet0 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 venet0 0.0.0.0 191.255.255.1 0.0.0.0 UG 0 0 0 venet0 Please note that a destination entry 0.0.0.0 (or default) is the default gateway. In above example 191.255.255.1 is a default gateway. Add / setup a new route The syntax is as follows: route add default gw {IP-ADDRESS} {INTERFACE-NAME} Where,  IP-ADDRESS: Specify router IP address  INTERFACE-NAME: Specify interface name such as eth0 For example if your router IP address is 192.168.1.254 type the following command as the root user: # route add default gw 192.168.1.254 eth0 OR use hostname such as dsl-router: # route add default gw dsl-router eth0 Or use the ip command (newer syntax) to route all traffic via 192.168.1.254 gateway connected via eth0 network interface: # ip route add 192.168.1.0/24 dev eth0 OR # ip route add 192.168.1.0/24 via 192.168.1.254 Setting route using GUI tools/command under Linux If you find above command hard to use, consider using GUI tools. If your are using Red Hat/CentOS/Fedora core Linux type following command:# redhat-config-networkOR If you are using other Linux distribution use command:# network-admin