久久机这里只有精品,国产69精品一区二区亚洲孕妇,91精品国产综合久久婷婷香蕉,午夜久久久久久电影

最新活動:電腦PC端+手機端+微網站+自適應網頁多模板選擇-建站388元起價?。?!
當前位置:主頁 > 網站建設 > 服務器網絡中轉,端口轉發腳本使用教程建站文

服務器網絡中轉,端口轉發腳本使用教程建站文

時間:2023-05-28 20:05:28 閱讀: 文章分類: 網站建設 作者: 網站技術員

導讀:建站文章建站文章 服務器網絡中轉,端口轉發腳本使用教程個人收藏wget -N --no-check-certificate https://raw.githubusercont網站seo優化課程網站建設哪家好。

網站seo優化課程網站建設哪家好

服務器網絡中轉,端口轉發腳本使用教程

個人收藏

wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubiBackup/doubi/master/iptables-pf.sh && chmod +x iptables-pf.sh && bash iptables-pf.sh

以下是配置過程的步驟

請輸入 iptables 欲轉發至的 遠程端口 [1-65535] (支持端口段 如 2333-6666, 被轉發服務器):

比如輸入:10000-11000

欲轉發端口 : 10000-11000

請輸入 iptables 欲轉發至的 遠程IP(被轉發服務器):

比如輸入:223.3.3.3

欲轉發服務器IP : 223.3.3.3

請輸入 iptables 本地監聽端口 [1-65535] (支持端口段 如 2333-6666) (默認端口: 10000-11000):

比如輸入:10000-11000

本地監聽端口 : 10000-11000

請輸入 本服務器的 公網IP網卡IP(注意是網卡綁定的IP,而不僅僅是公網IP,回車自動檢測):

本服務器IP : 1.1.1.1

比如輸入:1.1.1.1

請輸入數字 來選擇 iptables 轉發類型: 1. TCP 2. UDP 3. TCP+UDP

(默認: TCP+UDP):

比如輸入:3

請檢查 iptables 端口轉發規則配置是否有誤 !

本地監聽端口 : 10000-11000 服務器 IP : 223.3.3.3

欲轉發的端口 : 10000-11000 欲轉發 IP : 1.1.1.1 轉發類型 : TCP+UDP

腳本內容備份(防止哪天上面鏈接里的腳本被刪):

#!/usr/bin/env bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH #================================================= # System Required: CentOS/Debian/Ubuntu # Description: iptables Port forwarding # Version: 1.1.1 # Author: Toyo #================================================= sh_ver="1.1.1" Green_font_prefix="\033[32m" && Red_font_prefix="\033[31m" && Green_background_prefix="\033[42;37m" && Red_background_prefix="\033[41;37m" && Font_color_suffix="\033[0m" Info="${Green_font_prefix}[信息]${Font_color_suffix}" Error="${Red_font_prefix}[錯誤]${Font_color_suffix}" Tip="${Green_font_prefix}[注意]${Font_color_suffix}" check_iptables(){ iptables_exist=$(iptables -V) [[ ${iptables_exist} = "" ]] && echo -e "${Error} 沒有安裝iptables,請檢查 !" && exit 1 } check_sys(){ if [[ -f /etc/redhat-release ]]; then release="centos" elif cat /etc/issue | grep -q -E -i "debian"; then release="debian" elif cat /etc/issue | grep -q -E -i "ubuntu"; then release="ubuntu" elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat"; then release="centos" elif cat /proc/version | grep -q -E -i "debian"; then release="debian" elif cat /proc/version | grep -q -E -i "ubuntu"; then release="ubuntu" elif cat /proc/version | grep -q -E -i "centos|red hat|redhat"; then release="centos" fi #bit=`uname -m` } install_iptables(){ iptables_exist=$(iptables -V) if [[ ${iptables_exist} != "" ]]; then echo -e "${Info} 已經安裝iptables,繼續..." else echo -e "${Info} 檢測到未安裝 iptables,開始安裝..." if [[ ${release} == "centos" ]]; then yum update yum install -y iptables else apt-get update apt-get install -y iptables fi iptables_exist=$(iptables -V) if [[ ${iptables_exist} = "" ]]; then echo -e "${Error} 安裝iptables失敗,請檢查 !" && exit 1 else echo -e "${Info} iptables 安裝完成 !" fi fi echo -e "${Info} 開始配置 iptables !" Set_iptables echo -e "${Info} iptables 配置完畢 !" } Set_forwarding_port(){ read -e -p "請輸入 iptables 欲轉發至的 遠程端口 [1-65535] (支持端口段 如 2333-6666, 被轉發服務器):" forwarding_port [[ -z "${forwarding_port}" ]] && echo "取消..." && exit 1 echo && echo -e " 欲轉發端口 : ${Red_font_prefix}${forwarding_port}${Font_color_suffix}" && echo } Set_forwarding_ip(){ read -e -p "請輸入 iptables 欲轉發至的 遠程IP(被轉發服務器):" forwarding_ip [[ -z "${forwarding_ip}" ]] && echo "取消..." && exit 1 echo && echo -e " 欲轉發服務器IP : ${Red_font_prefix}${forwarding_ip}${Font_color_suffix}" && echo } Set_local_port(){ echo -e "請輸入 iptables 本地監聽端口 [1-65535] (支持端口段 如 2333-6666)" read -e -p "(默認端口: ${forwarding_port}):" local_port [[ -z "${local_port}" ]] && local_port="${forwarding_port}" echo && echo -e " 本地監聽端口 : ${Red_font_prefix}${local_port}${Font_color_suffix}" && echo } Set_local_ip(){ read -e -p "請輸入 本服務器的 網卡IP(注意是網卡綁定的IP,而不僅僅是公網IP,回車自動檢測外網IP):" local_ip if [[ -z "${local_ip}" ]]; then local_ip=$(wget -qO- -t1 -T2 ipinfo.io/ip) if [[ -z "${local_ip}" ]]; then echo "${Error} 無法檢測到本服務器的公網IP,請手動輸入" read -e -p "請輸入 本服務器的 網卡IP(注意是網卡綁定的IP,而不僅僅是公網IP):" local_ip [[ -z "${local_ip}" ]] && echo "取消..." && exit 1 fi fi echo && echo -e " 本服務器IP : ${Red_font_prefix}${local_ip}${Font_color_suffix}" && echo } Set_forwarding_type(){ echo -e "請輸入數字 來選擇 iptables 轉發類型: 1. TCP 2. UDP 3. TCP+UDP\n" read -e -p "(默認: TCP+UDP):" forwarding_type_num [[ -z "${forwarding_type_num}" ]] && forwar企業網站建設ding_type_num="3" if [[ ${forwarding_type_num} == "1" ]]; then forwarding_type="TCP" elif [[ ${forwarding_type_num} == "2" ]]; then forwarding_type="UDP" elif [[ ${forwarding_type_num} == "3" ]]; then forwarding_tseo網站優化培訓ype="TCP+UDP" else forwarding_type="TCP+UDP" fi } Set_Config(){ Set_forwarding_port Set_forwarding_ip Set_local_port Set_local_ip Set_forwarding_type echo && echo -e "—————————————————————————————— 請檢查 iptables 端口轉發規則配置是否有誤 !\n 本地監聽端口 : ${Green_font_prefix}${local_port}${Font_color_suffix} 服務器 IP\t: ${Green_font_prefix}${local_ip}${Font_color_suffix}\n 欲轉發的端口 : ${Green_font_prefix}${forwarding_port}${Font_color_suffix} 欲轉發 IP\t: ${Green_font_prefix}${forwarding_ip}${Font_color_suffix} 轉發類型\t: ${Green_font_prefix}${forwarding_type}${Font_color_suffix} ————————百度seo網站優化——————————————————————\n" read -e -p "請按任意鍵繼續,如有配置錯誤請使用 Ctrl+C 退出。" var } Add_forwarding(){ check_iptables Set_Config local_port=$(echo ${local_port} | sed 's/-/:/g') forwarding_port_1=$(echo ${forwarding_port} | sed 's/-/:/g') if [[ ${forwarding_type} == "TCP" ]]; then Add_iptables "tcp" elif [[ ${forwarding_type} == "UDP" ]]; then Add_iptables "udp" elif [[ ${forwarding_type} == "TCP+UDP" ]]; then Add_iptables "tcp" Add_iptables "udp" fi Save_iptables clear && echo && echo -e "—————————————————————————————— iptables 端口轉發規則配置完成 !\n 本地監聽端口 : ${Green_font_prefix}${local_port}${Font_color_suffix} 服務器 IP\t: ${Green_font_prefix}${local_ip}${Font_color_suffix}\n 欲轉發的端口 : ${Green_font_prefix}${forwarding_port_1}${Font_color_suffix} 欲轉發 IP\t: ${Green_font_prefix}${forwarding_ip}${Font_color_suffix} 轉發類型\t: ${Green_font_prefix}${forwarding_type}${Font_color_suffix} ——————————————————————————————\n" } View_forwarding(){ check_iptables forwarding_text=$(iptables -t nat -vnL PREROUTING|tail -n +3) [[ -z ${forwarding_text} ]] && echo -e "${Error} 沒有發現 iptables 端口轉發規則,請檢查 !" && exit 1 forwarding_total=$(echo -e "${forwarding_text}"|wc -l) forwarding_list_all="" for((integer = 1; integer /dev/null if [[ $? -eq 0 ]]; then if [[ ${Del_forwarding_num} -ge 1 ]] && [[ ${Del_forwarding_num} -le ${forwarding_total} ]]; then forwarding_type=$(echo -e "${forwarding_text}"| awk '{print $4}' | sed -n "${Del_forwarding_num}p") forwarding_listen=$(echo -e "${forwarding_text}"| awk '{print $11}' | sed -n "${Del_forwarding_num}p" | awk -F "dpt:" '{print $2}' | sed 's/-/:/g') [[ -z ${forwarding_listen} ]] && forwarding_listen=$(echo -e "${forwarding_text}"| awk '{print $11}' |sed -n "${Del_forwarding_num}p" | awk -F "dpts:" '{print $2}') Del_iptables "${forwarding_type}" "${Del_forwarding_num}" Save_iptables echo && echo -e "${Info} iptables 端口轉發規則刪除完成 !" && echo else echo -e "${Error} 請輸入正確的數字 !" fi else break && echo "取消..." fi done } Uninstall_forwarding(){ check_iptables echo -e "確定要清空 iptables 所有端口轉發規則 ? [y/N]" read -e -p "(默認: n):" unyn [[ -z ${unyn} ]] && unyn="n" if [[ ${unyn} == [Yy] ]]; then forwarding_text=$(iptables -t nat -vnL PREROUTING|tail -n +3) [[ -z ${forwarding_text} ]] && echo -e "${Error} 沒有發現 iptables 端口轉發規則,請檢查 !" && exit 1 forwarding_total=$(echo -e "${forwarding_text}"|wc -l) for((integer = 1; integer /etc/iptables.up.rules fi } Set_iptables(){ echo -e "net.ipv4.ip_forward=1" >> /etc/sysctl.conf sysctl -p if [[ ${release} == "centos" ]]; then service iptables save chkconfig --level 2345 iptables on else iptables-save > /etc/iptables.up.rules echo -e '#!/bin/bash\n/sbin/iptables-restore /etc/network/if-pre-up.d/iptables chmod +x /etc/network/if-pre-up.d/iptables fi } Update_Shell(){ sh_new_ver=$(wget --no-check-certificate -qO- -t1 -T3 "https://raw.githubusercontent.com/ToyoDAdoubiBackup/doubi/master/iptables-pf.sh"|grep 'sh_ver="'|awk -F "=" '{print $NF}'|sed 's/\"http://g'|head -1) [[ -z ${sh_new_ver} ]] && echo -e "${Error} 無法鏈接到 Github !" && exit 0 wget -N --no-check-certificate "https://raw.githubusercontent.com/ToyoDAdoubiBackup/doubi/master/iptables-pf.sh" && chmod +x iptables-pf.sh echo -e "腳本已更新為最新版本[ ${sh_new_ver} ] !(注意:因為更新方式為直接覆蓋當前運行的腳本,所以可能下面會提示一些報錯,無視即可)" && exit 0 } check_sys echo && echo -e " iptables 端口轉發一鍵管理腳本 ${Red_font_prefix}[v${sh_ver}]${Font_color_suffix} -- Toyo | doub.io/wlzy-20 -- ${Green_font_prefix}0.${Font_color_suffix} 升級腳本 ———————————— ${Green_font_prefix}1.${Font_color_suffix} 安裝 iptables ${Green_font_prefix}2.${Font_color_suffix} 清空 iptables 端口轉發 ———————————— ${Green_font_prefix}3.${Font_color_suffix} 查看 iptables 端口轉發 ${Green_font_prefix}4.${Font_color_suffix} 添加 iptables 端口轉發 ${Green_font_prefix}5.${Font_color_suffix} 刪除 iptables 端口轉發 ———————————— 注意:初次使用前請請務必執行 ${Green_font_prefix}1. 安裝 iptables${Font_color_suffix}(不僅僅是安裝)" && echo read -e -p " 請輸入數字 [0-5]:" num case "$num" in 0) Update_Shell ;; 1) install_iptables ;; 2) Uninstall_forwarding ;; 3) View_forwarding ;; 4) Add_forwarding ;; 5) Del_forwarding ;; *) echo "請輸入正確數字 [0-5]" ;; esac相關網站seo優化課程網站建設哪家好。

關鍵詞標簽: 中轉教程 端口轉發 網絡中轉 轉發教程

聲明: 本文由我的SEOUC技術文章主頁發布于:2023-05-28 ,文章服務器網絡中轉,端口轉發腳本使用教程建站文主要講述中轉教程,端口轉發,網絡中轉,轉發教程網站建設源碼以及服務器配置搭建相關技術文章。轉載請保留鏈接: http://www.bifwcx.com/article/web_11810.html

我的IDC 網站建設技術SEOUC.COM
專注網站建設,SEO優化,小程序設計制作搭建開發定制網站等,數千家網站定制開發案例,網站推廣技術服務。
  • 5000+合作客服
  • 8年從業經驗
  • 150+覆蓋行業
  • 最新熱門源碼技術文章

    主站蜘蛛池模板: 尼木县| 图木舒克市| 钦州市| 兴隆县| 奉新县| 开化县| 五莲县| 蓝田县| 新龙县| 金寨县| 凤翔县| 芜湖市| 乐都县| 海宁市| 额敏县| 永州市| 嘉峪关市| 临武县| 贵南县| 西城区| 信宜市| 神木县| 兴安盟| 临朐县| 十堰市| 曲松县| 万荣县| 长子县| 北辰区| 孝义市| 龙井市| 定远县| 监利县| 萝北县| 琼结县| 南安市| 伊宁县| 信阳市| 台湾省| 栾城县| 滁州市|