目前分類:NetYea (205)

瀏覽方式: 標題列表 簡短摘要

為了將圖片數據轉換為合適 AI訓練的花樣,使用 OpenCV先對面部進行辨識,然後將臉部數據另存為同一的格局。

網頁設計
  1. import cv2
  2.  
  3. face_cascade = cv2.CascadeClassifier('./cascades/haarcascade_frontalface_default.xml')
  4. eye_cascade = cv2.CascadeClassifier('./cascades/haarcascade_eye.xml')
  5.  
  6. def detect(filename):
  7.     img = cv2.imread(filename)
  8.     gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
  9.     faces = face_cascade.detectMultiScale(gray,
  10.                                           scaleFactor=1.2,
  11.                                           minNeighbors=3,)
  12.     for (x,y,w,h) in faces:
  13.         roi_gray = gray[y:y+h, x:x+w]
  14.         eyes = eye_cascade.detectMultiScale(roi_gray,
  15.                                             scaleFactor=1.02,
  16.                                             minNeighbors=3,
  17.                                             minSize=(40,40),)
  18.         img = cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
  19.         for (ex,ey,ew,eh) in eyes:
  20.             img = cv2.rectangle(img,(x+ex,y+ey),(x+ex+ew,y+ey+eh),(0,255,0),2)
  21.     cv2.imwrite('./tzuyu_face.jpg', img)
  22.  
  23. detect('tzuyu.jpg')
文章標籤

valeritmfov8 發表在 痞客邦 留言(0) 人氣()

NetYea套件新增Line@漂寶塔標
在電腦版或是手機板都能讓客戶更輕易找到你
文章標籤

valeritmfov8 發表在 痞客邦 留言(0) 人氣()

RGB LED依序為紅、最長腳、
RGB LED的共陽極(最長腳)串接一個330的電阻後再接地(GND)。

Arduino的 RGB led燈(共陽極)的使用 網頁設計
Arduino的 RGB led燈(共陽極)的使用 網頁設計
RGB LED的R接Arduino GPIO腳位16。
RGB LED的G接Arduino GPIO腳位17。
RGB LED的B接Arduino GPIO腳位5。

程式碼
1.每隔一秒改變LED的顏色,紅、綠、藍、黃、青、洋紅、白


 

文章標籤

valeritmfov8 發表在 痞客邦 留言(0) 人氣()

網頁設計DEMO圖片
STRENGTH.JS 暗碼強度檢查,利用 JQUERY 框STRENGTH.JS 暗碼強度檢查,利用 JQUERY 框

Strength.js 套件能用在註冊時就先搜檢暗碼的強度,現在良多網站都有會員機制,很多人怕暗碼會忘掉或是偷懶城市用一些很簡短簡單的密碼,這樣就讓其它惡意的利用者就有機可趁,這也讓網站的辦理者很頭大。

此套件主要的標準分數為:
密碼必須包括8個字符以上
暗碼必須包括1個小寫字母
密碼必須包含1個大寫字母
暗碼必需包括1個數字
當然有特殊的字元也是加分的環節

利用方法:
第一步 載入 JavaScripts 和 CSS 的樣式檔案

  1. <!-- 樣式檔案 -->
  2. <link href='strength.css' rel='stylesheet' type='text/css'>
  3. <!-- 使用 Google 的 API 獲得 jQuery-->
  4. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  5. <!-- Strength.js 的主程式檔案-->
  6. <script type="text/javascript" src="strength.js"></script>
文章標籤

valeritmfov8 發表在 痞客邦 留言(0) 人氣()

昨日要寄信到GMAIL信箱
發現CPanel SMTP泛起毛病

顯示 SMTP 毛病(-1)。與辦事器連線失敗
文章標籤

valeritmfov8 發表在 痞客邦 留言(0) 人氣()

因為信件發不出去(gmail hotmail 直接被退回)
問了CPanel官方後
他說hostname沒法對應,要改成與nameserver一樣
然後如何重建Exim PTR /保留DNS Cache 和更新MAIL HELO


進入WHM
Home »Service Configuration »Exim Configuration ManagerDocumentation



Rebuild Reverse DNS Cache and Update Mail HELO

 

文章標籤

valeritmfov8 發表在 痞客邦 留言(0) 人氣()

網頁設計

不管是利用無名、Pixnet、Xuite或Wordpress...等平台,在管理後台新增文章,都會有一個很像Word的編纂器,透過此編纂器就可輕鬆撰寫文章,而且還可以加粗體變換字體色彩超貫穿連接....與圖片上傳等功能,即使完全不懂任何的HTML語法,也可編纂出一個大度的文章頁面出來,而且邊製作還會邊顯示成果,這是個相當方便的功能,而這麼棒的功能難不成要自已寫,寫完不只天黑可能都爆肝了,所以要多加善用資本,今天梅干就來分享一個好用的即見即所得HTML文章編輯器CKeditor,與CKfinder上傳元件讓編輯器不只單單可編纂,同時還可上傳檔案乃至直瀏覽伺器服中的檔案,且完全不消寫任何的程式碼,只要設定一下,立即就打造自已專屬的文章編纂器囉!
 

CKeditor(編輯器)/CKfinder(上傳元件)下載:
編輯器:CKeditor
支援語法:PHP、ASP、ASP.NET、CF
元件版本:4.4.5
官方展現:http://ckeditor.com/demo
官方下載:http://ckeditor.com/download

上傳元件:CKfinder
支援語法:PHP、ASP、ASP.NET、CF
元件版本:2.4
官方展現:http://ckfinder.com/demo
官方下載:http://ckfinder.com/download
文章標籤

valeritmfov8 發表在 痞客邦 留言(0) 人氣()

進入OUTLOOK->帳戶設定


1.新增帳戶

網頁設計 Cpanel Email Outlook 設定

文章標籤

valeritmfov8 發表在 痞客邦 留言(0) 人氣()

有利用過進度條的同夥必然會感覺很不利便
因為要從0~100讀取 揮霍時候
因檔案巨細也不知道這時候間讀寫的完嗎?
如這篇網頁設計
Java Swing 若何利用進度

於是顛末批改
改成此方法
可操縱DIALOG準確的抓到讀寫完成的時候

  1. processdialog.setTitle("Copying files to USB");
  2.                             processdialog.add(labelimg);
  3.                             processdialog.setLocation(400,250);
  4.                             processdialog.pack(); // Packs the dialog so that the JOptionPane can be seen
  5.                             processdialog.setVisible(true); // Shows the dialog
  6.                             new Thread(){
  7.                                     public void run(){
  8.                                             try{
  9.                                                 Process process = null;網頁設計
  10.                                                 BufferedReader input = null;
  11.                                                 final Runtime runtime = Runtime.getRuntime();
  12.                                                 //extact tar for ext3 file
  13.                                                 String tarstring = "tar -xvpf /"+tarpath+"/"+cellValue+".tar -C "+extpatition+"/";
  14.                                                 process = runtime.exec(new String[]{"/bin/sh","-c",tarstring});
  15.                                                 InputStream stdout = process.getInputStream ();
  16.                                                 InputStreamReader osr = new InputStreamReader (stdout);
  17.                                                 BufferedReader obr = new BufferedReader (osr);
  18.                                                 process.waitFor();
  19.                                                
  20.                                                 Thread.sleep(2000);
  21.                                             }catch(Exception e){
  22.                                                     e.printStackTrace();
  23.                                             }finally{網頁設計
  24.                                                     processdialog.dispose();
  25.                                             }
  26.                                     }
  27.                             }.start();
文章標籤

valeritmfov8 發表在 痞客邦 留言(0) 人氣()


網頁設計 讓網頁表格能主動排序 TableSorter

一、TableSorter 介紹
網頁設計 讓網頁表格能主動排序 TableSorter
在所有 jQuery 表格排序外掛裡面,TableSorter 算是利用率最高的,並且擴充功能相當多(但紛歧定用獲得),因此本篇保舉這個工具。

1. 官網說明

https://mottie.github.io/tablesorter/docs/

下載檔案後找到這幾個檔案

 

文章標籤

valeritmfov8 發表在 痞客邦 留言(0) 人氣()

電腦中毒是不成避免的,Linux系統也是如斯,在得知系統中毒後,重要義務是找到病毒文件並將其斷根,在Linux系統下可以使用find敕令查找病毒,下面經由過程實例講解下find若何查找病毒。

電腦中毒Linux find號令快速查找中毒文件教程

文章標籤

valeritmfov8 發表在 痞客邦 留言(0) 人氣()

用nmcli可以成功建立pppoe連線
: (在下列例子中,我將pppoe連線定名為ppp0,刻意設定為需要時才手動進行撥接,
: 網卡的裝配名稱為對外enp1s0f0, 對內enp1s0f1)
1. 安裝模組 NetworkManager-ppp ppp
enp1s0f0設定IP:192.168.0.254
enp1s0f0設定IP:192.168.1.254

1.安裝模組

  1. dnf install NetworkManager-ppp -y
  2. dnf install ppp -y
文章標籤

valeritmfov8 發表在 痞客邦 留言(0) 人氣()

最近被MAIL SERVER搞得焦頭爛額
逐日到CPANEL官方問問題
結果都是沒找到被GAMIL及HOTMAIL檔信問題
也處置懲罰不了
找了小洲先生,他說只有做SmartHost relay或換IP



進入WHM -> Exim Configuration Manager -> BACKUP
備份設定檔
網頁設計 CPanel 若何用 Hinet 做 SmartH

最近被MAIL SERVER搞得焦頭爛額
逐日到CPANEL官方問問題
成績都是沒找到被GAMIL及HOTMAIL檔信問題
也處理不了
找了小洲先生,他說只有做SmartHost relay或換IP



進入WHM -> Exim Configuration Manager -> BACKUP
備份設定檔

網頁設計 CPanel 若何用 Hinet 做 SmartH

文章標籤

valeritmfov8 發表在 痞客邦 留言(0) 人氣()

申明:在Linux下把excel數據導入到mysql數據庫中,這其實是很搞笑的一個舉止!幾近很少有法式員研究過這個問題吧?如斯失常的問題,估計我是第一個研究的!呵呵,完滿是自找苦吃~~,但是今天完了這項太有挑戰性的工作!
先清算一下思緒先,~~
首先:需要把文件上傳到服務器上
然後:讀取excel數據列顯示出來
然後:讓用戶選擇字段的對應關係
然後:提交數據,讀取字段的對應關係
最後:批量導入數據,刪除且自文件
一共是以上五步調!我們一步步剖析~~~
第一步:下載附件中的phpexcelparser4.rar ,這個文件是上傳excel盜服務器上並以web情勢展現出來的!這個一般沒有問題的!問題是法式的做法是把表存為姑且表而沒有真正保留下來,所以起首要更改法式代碼為

 

  1.  
  2. //uc轉換成html
  3. function uc2html($str) {
  4.    $ret = '';
  5.    for( $i=0; $i<strlen($str)/2; $i++ ) {
  6.        $charcode = ord($str[$i*2])+256*ord($str[$i*2+1]);
  7.        // $ret .= '&#'.$charcode;
  8.        if($charcode<127)
  9.          $ret .=chr($charcode);
  10.        else
  11.            $ret .= iconv("utf-8","utf-8",u2utf8($charcode));
  12.    }
  13.        return $ret;
  14. }
  15. //html轉成utf8
  16. function u2utf8($c) {
  17. $str="";
  18. if ($c < 0x80) {
  19.   $str.=$c;
  20. } else if ($c < 0x800) {
  21.   $str.=chr(0xC0 | $c>>6);
  22.   $str.=chr(0x80 | $c & 0x3F);
  23. } else if ($c < 0x10000) {
  24.   $str.=chr(0xE0 | $c>>12);
  25.   $str.=chr(0x80 | $c>>6 & 0x3F);
  26.   $str.=chr(0x80 | $c & 0x3F);
  27. } else if ($c < 0x200000) {
  28.   $str.=chr(0xF0 | $c>>18);
  29.   $str.=chr(0x80 | $c>>12 & 0x3F);
  30.   $str.=chr(0x80 | $c>>6 & 0x3F);
  31.   $str.=chr(0x80 | $c & 0x3F);
  32. }
  33. return $str;
  34. }
  35.  
  36. if (trim($_POST["cmd"])=="upload")
  37. {
  38. $err_corr = "Unsupported format or file corrupted";
  39. $excel_file_size;
  40. $excel_file = $_FILES['excel_file'];
  41. $uploadservername=$UploadAbsPath."tmpexcel/".$_FILES['excel_file']['name'];
  42. echo($uploadservername);
  43.      if (!is_writeable($UploadAbsPath."tmpexcel/"))
  44.      {
  45.      echo "目次弗成寫!"; exit;
  46.      }
  47.      else
  48.      {
  49.      echo "目次可寫!";
  50.      }
  51. if (move_uploaded_file($_FILES['excel_file']['tmp_name'], $uploadservername))
  52. {
  53.     echo("上傳成功");
  54. }
  55. else
  56. {
  57.     echo("上傳失敗");
  58. }
  59. $excel_file=$uploadservername;
  60. //if( $excel_file )
  61. //    $excel_file = $_FILES['excel_file']['tmp_name'];網頁設計
  62.  
  63.  
  64. if( $excel_file == '' ) fatal("No file uploaded");
  65.  
  66.  
  67. $exc = new ExcelFileParser("debug.log", ABC_NO_LOG);//ABC_NO_LOG ABC_VAR_DUMP);
  68.     //echo($excel_file."|");
  69.    
  70. $style = $_POST['style'];
  71. if( $style == 'old' )
  72. {
  73.     $fh = @fopen ($excel_file,'rb');
  74.     if( !$fh ) fatal("No file uploaded");
  75.     if( filesize($excel_file)==0 ) fatal("No file uploaded");
  76.     $fc = fread( $fh, filesize($excel_file) );
  77.     @fclose($fh);
  78.     if( strlen($fc) < filesize($excel_file) )
  79.     fatal("Cannot read file");
  80.    
  81.     $time_start = getmicrotime();
  82.     $res = $exc->ParseFromString($fc);
  83.     $time_end = getmicrotime();
  84. }
  85. elseif( $style == 'segment' )
  86. {
  87.     $time_start = getmicrotime();
  88.     $res = $exc->ParseFromFile($excel_file);
  89.     $time_end = getmicrotime();
  90. }
  91.  
  92.  
  93. switch ($res) {
  94.     case 0: break;
  95.     case 1: fatal("Can't open file");
  96.     case 2: fatal("File too small to be an Excel file");
  97.     case 3: fatal("Error reading file header");
  98.     case 4: fatal("Error reading file");
  99.     case 5: fatal("This is not an Excel file or file stored in Excel < 5.0");
  100.     case 6: fatal("File corrupted");
  101.     case 7: fatal("No Excel data found in file");
  102.     case 8: fatal("Unsupported file version");
  103.  
  104.  
  105.     default:
  106.     fatal("Unknown error");
  107. }
  108.  
  109.  
  110. /*
  111. print '<pre>';
  112. print_r( $exc );
  113. print '</pre>';
  114. exit;
  115. */
  116.  
  117.  
  118. show_time();
  119.  
  120.  
  121. echo <<<LEG
  122. <b>Legend:</b><br><br>
  123. <form name='doform' action='' method='post'>
  124. <input type='hidden' name='action' value='do'>
  125. <input type='hidden' name='excel_file' value=$excel_file>
  126. <input type='hidden' name='style' value=$style>
  127. <table border=1 cellspacing=0 cellpadding=0>
  128. <tr><td>Data type</td><td>Description</td></tr>
  129. <tr><td class=empty>&nbsp;</td><td class=index>An empty cell</td></tr>
  130. <tr><td class=dt_string>ABCabc</td><td class=index>String</td></tr>
  131. <tr><td class=dt_int>12345</td><td class=index>Integer</td></tr>
  132. <tr><td class=dt_float>123.45</td><td class=index>Float</td></tr>
  133. <tr><td class=dt_date>123.45</td><td class=index>Date</td></tr>
  134. <table>
  135. <br><br>
  136.  
  137.  
  138. LEG;
  139. /*
  140. print "<pre>";
  141. print_r ($exc->worksheet);
  142. print_r($exc->sst);
  143. print "</pre>";
  144. */
  145.     for( $ws_num=0; $ws_num<count($exc->worksheet['name']); $ws_num++ )
  146.     {
  147.     print "<b>Worksheet: \"";
  148.     if( $exc->worksheet['unicode'][$ws_num] ) {
  149.     print uc2html($exc->worksheet['name'][$ws_num]);網頁設計
  150.     } else
  151.     print $exc->worksheet['name'][$ws_num];
  152.  
  153.  
  154.     print "\"</b>";
  155.     $ws = $exc->worksheet['data'][$ws_num];
  156.  
  157.  
  158.     if( is_array($ws) &&
  159.          isset($ws['max_row']) && isset($ws['max_col']) ) {
  160.      echo "\n<br><br><table border=1 cellspacing=0 cellpadding=2>\n";
  161.  
  162.  
  163.      print "<tr><td>&nbsp;</td>\n";
  164.      for( $j=0; $j<=$ws['max_col']; $j++ ) {
  165.     print "<td class=index>&nbsp;";
  166.     if( $j>25 ) print chr((int)($j/26)+64);
  167.     //這裡要顯示一個下拉列表來顯示數據
  168.     //注意是循環數據<br />
  169.     echo("\n<select name='".$j."'>");
  170.     echo("\n<option value='0'>不選擇</option>");
  171.    echo("\n<option value='costomernum'>客戶編號</option>");
  172.    echo("\n<option value='name'>客戶姓名</option>");
  173.    echo("\n<option value='phone1'>德律風1</option>");
  174.    echo("\n<option value='phone2'>電話2</option>");
  175.    echo("\n<option value='address1'>地址1</option>");
  176.    echo("\n<option value='address2'>地址2</option>");  
  177.    echo("\n<option value='company'>公司</option>");
  178.    echo("\n<option value='levelc'>職稱</option>");   
  179.    echo("\n<option value='ps'>備註</option>");
  180.    
  181.     echo("</select>");
  182.     print "</td>";
  183.      }
  184.  
  185.  
  186.      print "<tr><td>&nbsp;</td>\n";
  187.      for( $j=0; $j<=$ws['max_col']; $j++ ) {
  188.     print "<td class=index>&nbsp;";
  189.     if( $j>25 ) print chr((int)($j/26)+64);
  190.     print chr(($j % 26) + 65)."&nbsp;列名</td>";
  191.      }
  192.  
  193.  
  194.  
  195. //表頭輸出終了
  196.     if ($ws['max_row']>9)
  197.     {
  198.     $shownum=9;
  199.     }
  200.     else
  201.     {
  202.     $shownum=$ws['max_row'];//只輸出前10條數據
  203.     }
  204.      for( $i=0; $i<=$shownum; $i++ ) {
  205.      print "<tr><td class=index>".($i+1)."</td>\n";
  206.      if(isset($ws['cell'][$i]) && is_array($ws['cell'][$i]) ) {
  207.          for( $j=0; $j<=$ws['max_col']; $j++ ) {
  208.  
  209.  
  210.     if( ( is_array($ws['cell'][$i]) ) &&
  211.          ( isset($ws['cell'][$i][$j]) )
  212.          ){
  213.  
  214.  
  215.      // print cell data
  216.      print "<td class=\"";
  217.      $data = $ws['cell'][$i][$j];
  218.  
  219.  
  220.      $font = $ws['cell'][$i][$j]['font'];
  221.      $style = " style ='".ExcelFont::ExcelToCSS($exc->fonts[$font])."'";
  222.  
  223.  
  224.          switch ($data['type']) {
  225.     // string
  226.     case 0:
  227.         print "dt_string\"".$style.">";
  228.         $ind = $data['data'];
  229.         if( $exc->sst['unicode'][$ind] ) {
  230.         $s = uc2html($exc->sst['data'][$ind]);
  231.         } else
  232.         $s = $exc->sst['data'][$ind];
  233.         if( strlen(trim($s))==0 )
  234.         print "&nbsp;";
  235.         else
  236.         print $s;
  237.         break;
  238.     // integer number
  239.     case 1:
  240.         print "dt_int\"".$style.">&nbsp;";
  241.         print $data['data'];
  242.         break;
  243.     // float number
  244.     case 2:
  245.         print "dt_float\"".$style.">&nbsp;";
  246.         echo $data['data'];
  247.         break;
  248.     // date
  249.     case 3:
  250.         print "dt_date\"".$style.">&nbsp;";
  251.  
  252.  
  253.         $ret = $data[data];//str_replace ( " 00:00:00", "", gmdate("d-m-Y H:i:s",$exc->xls2tstamp($data[data])) );
  254.         echo ( $ret );
  255.         break;
  256.     default:
  257.         print "dt_unknown\"".$style."> &nbsp;";網頁設計
  258.         break;
  259.          }
  260.      print "</td>\n";
  261.     } else {
  262.         print "<td class=empty>&nbsp;</td>\n";
  263.     }
  264.          }
  265.      } else {
  266.     // print an empty row
  267.     for( $j=0; $j<=$ws['max_col']; $j++ )
  268.         print "<td class=empty>&nbsp;</td>";
  269.     print "\n";
  270.      }
  271.      print "</tr>\n";
  272.      }
  273.  
  274.  
  275.      echo "</table><br>\n";
  276.     } else {
  277.     // emtpty worksheet
  278.     print "<b> - empty</b><br>\n";
  279.     }
  280.     print "<br>";
  281.  
  282.  
  283.     }
  284.     echo("<input type='submit' name='Submit' value='轉換' />");
  285.     echo("</form>");
  286. /*    print "Formats<br>";
  287.     foreach($exc->format as $value) {
  288.     printf("( %x )",array_search($value,$exc->format));
  289.     print htmlentities($value,ENT_QUOTES);
  290.     print "<br>";
  291.     }
  292.  
  293.  
  294.      print "XFs<br>";
  295.     for( $i=0;$i<count($exc->xf['format']);$i++) {
  296.     printf ("(%x)",$i);
  297.     printf (" format (%x) font (%x)",$exc->xf['format'][$i],$exc->xf['font'][$i]);
  298.  
  299.  
  300.     print "<br>";
  301.     }
  302. */
  303. }
文章標籤

valeritmfov8 發表在 痞客邦 留言(0) 人氣()

有在利用Google Maps的人,多幾多少必然都有利用到Google地圖找附近景點餐廳。

網頁設計 

文章標籤

valeritmfov8 發表在 痞客邦 留言(0) 人氣()

先到 pytorch 官網 對應一下CUDA版本及指令
YOLOv8 pytorch環境建置與講授 - Win10YOLOv8 pytorch情況建置與教授教養 - Win10
我的情況是:

  • Python 3.10
  • Nvidia driver 522.25
  • Cuda 11.7
  • Conda
  • Cudnn 8.7

安裝方式可參閱此篇文章 :Win10用 Anaconda 建 3070系列的 Tensorflow 深度進修情況


先下載CUDA 11.7 載點

下載安裝好今後,把CUDNN 三個目次COPY到C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7下


到PyCharm 終端機下指令先建一個虛擬情況

文章標籤

valeritmfov8 發表在 痞客邦 留言(0) 人氣()

許多人用BootStrap 圖片因寬度縮小視起來很歡快

可是縮得太小的時候,高度會達到最小高度是以沒法往下縮

會造成圖片變形,如圖

網頁設計 BootStrap img-responsive

文章標籤

valeritmfov8 發表在 痞客邦 留言(0) 人氣()


網頁設計 讓網頁表格能自動排序 TableSorter

1、TableSorter 介紹
網頁設計 讓網頁表格能自動排序 TableSorter
在所有 jQuery 表格排序外掛裡面,TableSorter 算是利用率最高的,並且擴充功能相當多(但不一定用獲得),因此本篇保舉這個工具。

1. 官網申明

https://mottie.github.io/tablesorter/docs/

下載檔案後找到這幾個檔案

 

文章標籤

valeritmfov8 發表在 痞客邦 留言(0) 人氣()

cxSelect 是基於jQuery 的多級聯動菜單插件,合用於省市、商品分類等聯動菜單。
列表數據經由過程AJAX 獲得,也能夠自界說,數據內容利用JSON 格式。
同時兼容Zepto,利便在移動端利用。
國內省市縣數據起原:basecss/cityData Date: 2014.03.31
全球首要城市數據起原:整頓國內常用網站和軟件Date: 2014.07.29


版本:jQuery的V1.7 +的Zepto V1.0 +jQuery的cxSelect V1.4.0


利用方式载入 JavaScript 文件

文章標籤

valeritmfov8 發表在 痞客邦 留言(0) 人氣()

比來因為CENTOS 7 辦事會莫名的關閉,查了發現是KENERL問題,所以決定升到CENTOS 8-9,

我的INTEL雙網網卡 來當做家裡的firewall, 於是安裝了CENTOS 8 - 9, 並用pppoe 來毗連中華電信的Router, 而且寫了一些iptables 的rules 來看成firewall 及NAT router.
然則感覺有問題, 有時連不出去. 現象是如許的:


但是在NAT 後面的電腦,GOOGLE PTT網站 連線都很ok, , 只要碰上yahoo跟遊戲 的連線, 就連不上, ftp 也ok.


這問題擺了良久都沒去理會. 今天終於有空好好的來追問題的源頭. 發現如同是跟pppoe 有關.
問了小洲大大才發現

MTU
MTU (Maximum Transmission Unit) 是指網路介面卡上最大傳輸單位, 其單位為bytes. 在大大都的Ehternet 上, 這個值凡是是1500. 因為如斯, 在PPPoE 中, 因為還有header問題, 所以這個值就得設的比力小, 平常為1492 (= 1500 – 2(PPP)- 6(PPPoE))

MSS
MSS (Maximum segment size) 是TCP protocol 中的一個參數, 是指TCP 每次資料傳輸分段的最大值. 當TCP 在handshake 時, 兩邊host 會查看MSS 這個欄位, 來決意兩邊資料傳輸分段的大小. 在Ethernet 中MSS 值最大為1460 bytes.
緣由是在Ethernet 中 MTU = IP Header + TCP Header + MSS + FCS.
(FCS 是指Frame check sequence, 平常採用CRC演算法, 在Ethernet 中, 它佔4 bytes.)
可是在PPPoE 中MTU 為1492, 所以其MSS 只能設為1452.

問題所在
當CENTOS 8 在開機後, 啟動了ppp0, 其內定將MTU 設為1492, 而且會自動設定一條iptable rule,



因為在NAT 後面的電腦, 其實不知道前真個router 是用什麼介面連到internet, 所以它和遠端的電腦創設TCP 連線時, 有可能會將MSS 設為1460. 然則由於firewall 或router 端利用PPPoE連線, 若MSS 大於1452會造成資料爆掉, 所以上述的iptable rule 強迫偷改其MSS值(在IPV4下 = PMTU – 40, 在IPV6下 = PMTU – 60). 是以MSS 就會被改成1452, 這樣子就不會爆掉了.

可是我本身寫的iptable rule script 中, 一最先就用了以下設定, 斷根了本來的所有設定

 

  1. # 清除所有規則
  2. iptables -F -t filter
  3. iptables -X -t filter
  4. iptables -Z -t filter
  5. iptables -F -t mangle
  6. iptables -X -t mangle
  7. iptables -Z -t mangle
  8. iptables -F -t nat
  9. iptables -X -t nat
  10. iptables -Z -t nat
文章標籤

valeritmfov8 發表在 痞客邦 留言(0) 人氣()