參考
https://blog.gtwang.org/linux/linux-utility-netcat-examples/
檔案接收者
nc -l 5000 > branch-rtl819x-sdk-v3.4.11.tar
nc 172.21.69.1 5000 < branch-rtl819x-sdk-v3.4.11.tar
nc -l 50000 > my_svn_new_checkout.sh
nc 172.21.69.4 5000 < my_svn_new_checkout.sh
在兩台主機之間複製檔案
假設現在有兩台主機,分別為 A 主機與 B 主機,若要將一個檔案從 A 主機複製到 B 主機,可以先在 B 主機(檔案接收者)上執行:
nc -l 5000 > my.jpg
然後在 A 主機(檔案傳送者)上執行:
nc hostB.com 5000 < my.jpg
這樣就可以把 my.jpg 這個檔案從 A 主機複製到 B 主機上了。 雖然這個方式跟 scp 指令比起來可能不是最方便的,但是它的特點是不需要登入的動作(也就是說不需要任何帳號與密碼),假設你碰到兩台主機無法互相登入的時候,就可以使用這樣的方式處理。
接收端
ubuntu 18.04
nc -l 50000 > my_svn_new_checkout.sh
傳送端
debian 9.6
nc 172.21.69.4 50000 -q 1 < my_svn_new_checkout.sh
傳送端
ubuntu 18.04
nc 172.21.15.145 50000 -q 1 < my_svn_new_checkout.sh
-N shutdown(2) the network socket after EOF on the input. Some servers
require this to finish their work.
centos 7 防火牆 注意
sudo firewall-cmd --zone=public --add-port=50000-55500/tcp --permanent
sudo firewall-cmd --reload
sudo firewall-cmd --zone=public --list-ports
19999/tcp 5001/tcp 5201/tcp 50000-55500/tcp
centos firewall reference
https://unix.stackexchange.com/questions/409878/centos-7-open-a-port
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-using-firewalld-on-centos-7
https://mangolassi.it/topic/8380/centos-7-open-firewall-ports-range-on-firewalld
https://www.thegeekdiary.com/how-to-test-port-connectivity-using-nc-utility-in-centos-rhel/
netcat 參考
https://www.linuxtechi.com/nc-ncat-command-examples-linux-systems/
https://www.arthurtoday.com/2015/10/ubuntu-replace-telnet-with-nc-command.html
https://www.tecmint.com/check-remote-port-in-linux/
https://ithelp.ithome.com.tw/articles/10136033
firewall and netcat
https://fabianlee.org/2016/09/26/ubuntu-pre-validate-network-acl-and-firewall-connectivity-with-netcat/
https://itekblog.com/test-firewall-with-netcat/
https://www.digitalocean.com/community/tutorials/how-to-use-netcat-to-establish-and-test-tcp-and-udp-connections-on-a-vps
debian firewall
https://wiki.debian.org/DebianFirewall
netcat for window 下載
https://eternallybored.org/misc/netcat/
dd if=/dev/zero of=10g.img bs=1 count=0 seek=10G
回覆刪除搭配 pv 可以看傳輸速度。
pv 10g.img | nc 172.21.15.141 50000 -q 1
pv 10g.img | nc 172.21.15.141 50000 -q 1
10GiB 0:01:35 [ 107MiB/s] [==================================================================>] 100%
scp jwsyu@172.21.15.188:/ssd/home_ssd/10g.img 10g.img2
jwsyu@172.21.15.188's password:
10g.img 100% 10GB 103.0MB/s 01:39
和scp比起來 10gb檔案 copy 快了4秒鐘
centos8 network
回覆刪除/etc/sysconfig/network-scripts/ ifcfg-xxx
ONBOOT=yes