要刪除括號內的文字,可以找出它們,然後將它們替換為空白。
1。 按 Ctrl + H 鍵來啟用 查找和替換 對話框中 查找內容 文本框,輸入 (*) 進入它,然後去 更換 文本框,輸入 () 進去。 看截圖:
2。 然後點擊 “全部替換”。 然後會彈出一個對話框提醒您更換次數。 點擊 OK 關閉它。
相關函數
儲存格C2:=LEFT(B2,FIND("(",B2)-1)
要刪除括號內的文字,可以找出它們,然後將它們替換為空白。
1。 按 Ctrl + H 鍵來啟用 查找和替換 對話框中 查找內容 文本框,輸入 (*) 進入它,然後去 更換 文本框,輸入 () 進去。 看截圖:
2。 然後點擊 “全部替換”。 然後會彈出一個對話框提醒您更換次數。 點擊 OK 關閉它。
相關函數
儲存格C2:=LEFT(B2,FIND("(",B2)-1)
參考網址:https://www.cyberciti.biz/tips/linux-iptables-how-to-specify-a-range-of-ip-addresses-or-ports.html
For example, allow incoming request on a port 22 for source IP in the 192.168.1.100-192.168.1.200 range only. You need to add something as follows to your iptables script:
iptables -A INPUT -p tcp --destination-port 22 -m iprange --src-range 192.168.1.100-192.168.1.200 -j ACCEPT
if –protocol tcp (-p tcp) is specified, you can specify source port range with following syntax:
And destination port range specification with following option :
For example block lock all incoming ssh access at port 22, for source port range 513:65535:
iptables -A INPUT -p tcp -s 0/0 --sport 513:65535 -d 195.55.55.78 --dport 22 -m state --state NEW,ESTABLISHED -j DROP
環境ubuntu 16.04
做為防火牆的主機需有兩張網卡
用ifconfig指令可以看到網卡名稱
現今ubuntu系統會以BIOS中網卡的名稱作為預設名稱
改法:
編輯/etc/default/grub
#GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash net.ifnames=0 biosdevname=0"
再執行
update-grub
reboot
eth0:192.168.1.11對外
eth1:192.168.0.3對內 不設通訊閘
clear.sh
#!/bin/sh IPTABLES="/sbin/iptables" /sbin/modprobe ip_conntrack /sbin/modprobe ip_conntrack_ftp /sbin/modprobe iptable_nat /sbin/modprobe ip_nat_ftp ###-----------------------------------------------------### # 打開 forward ###-----------------------------------------------------### #echo "Enable ip_forward ......" #echo echo "1" > /proc/sys/net/ipv4/ip_forward ###-----------------------------------------------------### # 清除先前的設定 ###-----------------------------------------------------### echo "Flush fiter table ......" echo # Flush filter $IPTABLES -F $IPTABLES -X echo "Flush mangle table ......" echo # Flush mangle $IPTABLES -F -t mangle $IPTABLES -t mangle -X echo "Flush nat table ......" echo # Flush nat $IPTABLES -F -t nat $IPTABLES -t nat -X ###-----------------------------------------------------### # 設定 filter table 的預設政策 ###-----------------------------------------------------### $IPTABLES -P INPUT ACCEPT $IPTABLES -P OUTPUT ACCEPT $IPTABLES -P FORWARD ACCEPT
分享
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.0.0/24 -j MASQUERADE
DHCP
apt install isc-dhcp-server
編輯/etc/default下的isc-dhcp-server
INTERFACES="eth1"
/etc/dhcp/dhcpd.conf
subnet 192.168.0.0 netmask 255.255.255.0 { range 192.168.0.201 192.168.0.250; option domain-name-servers 168.95.1.1; # option domain-name "internal.example.org"; # option subnet-mask 255.255.255.224; option routers 192.168.0.3; option broadcast-address 192.168.0.255; default-lease-time 600; max-lease-time 7200; } #subnet 192.168.1.0 netmask 255.255.255.0 { #}
service isc-dhcp-server restart 重啟dhcpd
service isc-dhcp-server status 可以看到目前dhcpd的狀態
● isc-dhcp-server.service - ISC DHCP IPv4 server Loaded: loaded (/lib/systemd/system/isc-dhcp-server.service; enabled; vendor preset Active: active (running) since 日 2019-12-15 03:57:46 CST; 1h 26min ago Docs: man:dhcpd(8) Main PID: 1739 (dhcpd) CGroup: /system.slice/isc-dhcp-server.service └─1739 dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dhcpd.pid -cf /etc/dhcp/dhcpd.conf eth1 12月 15 05:02:02 sa-5750G dhcpd[1739]: DHCPREQUEST for 192.168.0.201 from 94:de:80:xx: 12月 15 05:02:02 sa-5750G dhcpd[1739]: DHCPACK on 192.168.0.201 to 94:de:80:xx:xx:xx ( 12月 15 05:07:02 sa-5750G dhcpd[1739]: DHCPREQUEST for 192.168.0.201 from 94:de:80:xx: 12月 15 05:07:02 sa-5750G dhcpd[1739]: DHCPACK on 192.168.0.201 to 94:de:80:xx:xx:xx ( 12月 15 05:12:02 sa-5750G dhcpd[1739]: DHCPREQUEST for 192.168.0.201 from 94:de:80:xx: 12月 15 05:12:02 sa-5750G dhcpd[1739]: DHCPACK on 192.168.0.201 to 94:de:80:e9:5e:df ( 12月 15 05:17:03 sa-5750G dhcpd[1739]: DHCPREQUEST for 192.168.0.201 from 94:de:80:xx: 12月 15 05:17:03 sa-5750G dhcpd[1739]: DHCPACK on 192.168.0.201 to 94:de:80:xx:xx:xx ( 12月 15 05:22:03 sa-5750G dhcpd[1739]: DHCPREQUEST for 192.168.0.201 from 94:de:80:xx: 12月 15 05:22:03 sa-5750G dhcpd[1739]: DHCPACK on 192.168.0.201 to 94:de:80:xx:xx:xx (
配發的ip會記錄在/var/lib/dhcp/dhcpd.leases
iptables實作
iptables規則列撰原則
特例一
特例二
特例三
…….
預設規則
只允許可以上scratch.mit.edu
iptables -A FORWARD -o eth0 -p tcp -d scratch.mit.edu --dport 80 -j ACCEPT iptables -A FORWARD -o eth0 -p tcp -d scratch.mit.edu --dport 443 -j ACCEPT iptables -A FORWARD -o eth0 -p tcp --dport 80 -j DROP iptables -A FORWARD -o eth0 -p tcp --dport 443 -j DROP
結果scratch.mit.edu是個龐大的網站有很多IP
連到首頁還可以,往下的連結會有問題
安裝iptraf檢視連線的IP
apt install iptraf
另一套檢視連線軟體
apt install tcptrack
tcptrack -i eth1
#!/bin/sh iptables -A FORWARD -o eth0 -p tcp -d scratch.mit.edu --dport 80 -j ACCEPT iptables -A FORWARD -o eth0 -p tcp -d scratch.mit.edu --dport 443 -j ACCEPT iptables -A FORWARD -o eth0 -p tcp -d 151.101.230.133 --dport 80 -j ACCEPT iptables -A FORWARD -o eth0 -p tcp -d 151.101.230.133 --dport 443 -j ACCEPT #以下的IP也要開放才會正常(應該是google的IP) iptables -A FORWARD -o eth0 -p tcp -d 172.217.0.0/16 --dport 443 -j ACCEPT iptables -A FORWARD -o eth0 -p tcp --dport 80 -j DROP iptables -A FORWARD -o eth0 -p tcp --dport 443 -j DROP
參考網址:https://www.itread01.com/p/916977.html
前段時間銀行客戶開了個體驗區,是想讓大家體驗下他們的網銀,但是發現很多使用者卻通過電腦上百度,上微博啥的,他們卻只想讓使用者訪問他們的網銀系統。
辦法1 修改Hosts檔案
hosts檔案位於 Windows/system32/drivers/etc/目錄下,用於控制域名訪問。我想到的辦法修改hosts檔案,讓DNS域名解析這些網站都指向127.0.0.1,如下:
127.0.0.1 www.baidu.com
127.0.0.1 www.qq.com
……
但是,不可能把所有的域名都寫一遍吧,有人問用 127.0.0.1 * 可不可以?答案是不可以,因為hosts檔案不支援萬用字元。
所以這個方法理論可行,但實際不可行。
辦法2 通過Hosts檔案和網路設定控制
1.在網路設定裡面將DNS伺服器設定成 127.0.0.1,網路連結狀態-> TCP/IPv4 -> 屬性 -> 首選DNS伺服器 -> 127.0.0.1
這時候,你會發現,開啟瀏覽器通過域名訪問任何網頁都是不行的(但是通過IP可以,但這樣至少可以遮蔽掉95%的使用者,因為
大多數使用者只記得域名,不可能記得伺服器IP).
2.修改hosts檔案,指定不被禁止的域名。比如:61.135.169.125 www.baidu.com, 此時,訪問www.baidu.com時,就不是通過DNS服務 器了,而是直接對映到 61.135.169.125了。
上述的方法大家可以試試,雖然不是非常完美的解決方案,但確實很簡單。
另有一篇文章 https://blog.gtwang.org/windows/windows-linux-hosts-file-configuration/
Windows 的 hosts 檔不支援萬用字元(wildcards),可能要改用類似 Acrylic DNS Proxy 的方式。
參考網址:https://ubuntuforums.org/showthread.php?t=2137578
sudo apt-get install bcmwl-kernel-source
參考網址:http://blog.7311.tw/2014/05/mysqlmssql.html
複製一筆資料
MySQL、MSSQL 都可使用
INSERT INTO test( id, name, test1, test2 ) SELECT 3 AS id, name, 'test' AS test1, test2 FROM test WHERE id =1
* 要複製原來的值就不用AS
參考網址:https://caloskao.org/mysql-%E5%9C%A8%E5%90%8C%E4%B8%80%E5%BC%B5%E8%B3%87%E6%96%99%E8%A1%A8%E9%80%B2%E8%A1%8C%E8%A4%87%E8%A3%BD%E8%B3%87%E6%96%99%E7%9A%84%E6%93%8D%E4%BD%9C/
由於先dump出來再操作實在是覺得有點麻煩又有點蠢
想到應該可以直接下SQL來完成這件事情
於是稍微研究了一下
基本上只要避開primary column即可完成
參考網址:https://www.sanwebe.com/2013/03/addremove-input-fields-dynamically-with-jquery
https://dotblogs.com.tw/newmonkey48/2016/12/14/180815
$(document).ready(function() { var max_fields = 10; //maximum input boxes allowed var wrapper = $(".input_fields_wrap"); //Fields wrapper var add_button = $(".add_field_button"); //Add button ID var x = 1; //initlal text box count $(add_button).click(function(e){ //on add input button click e.preventDefault(); if(x < max_fields){ //max input box allowed x++; //text box increment $(wrapper).append('<div><input type="text" name="mytext[]"/><a href="#" class="remove_field">Remove</a></div>'); //add input box } }); $(wrapper).on("click",".remove_field", function(e){ //user click on remove text e.preventDefault(); $(this).parent('div').remove(); x--; }) });
<div class="input_fields_wrap"> <button class="add_field_button">Add More Fields</button> <div><input type="text" name="mytext[]"></div> </div>
參考網址:https://angularjs.org/
逛網站時,發現這個網站設計得很不錯。2020臺南古都國際半程馬拉松
有用了angularjs的技術
前端工程的極致精品: AngularJS 開發框架介紹