標籤:blank linux target style title
學會查看及測試網路
學會設定網路地址參數
查看網路介面的資訊ifconfig
格式:ifconfig 網路介面名
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M01/6D/B2/wKioL1Vpu1PwTCBYAAEebuL4UN4508.jpg" width="550" height="200" />
hostname命令:查看或設定當前主機名稱
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M01/6D/B6/wKiom1Vpub7yBm1vAABcpyLo3OQ734.jpg" width="529" height="102" />
bash啟用新的shell會話
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M02/6D/B2/wKioL1Vpu1WRlYVaAABhXETkZ_Y900.jpg" width="518" height="111" />
查看路由條目route
route命令:查看或設定主機中路由表資訊
格式:route –n
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M01/6D/B6/wKiom1VpucDT3FDiAABYby9e5dk890.jpg" width="536" height="66" />
查看網路連接情況netstat
netstat命令:查看系統的網路的串連狀態,路由表,介面統計資訊
格式:netstat [選項]
常用選項:
-a:顯示所有活動串連
-n:以數字形式顯示
-p:顯示進程資訊
-t:查看TCP協議相關資訊
-u:查看UDP協議相關資訊
-r:顯示路由表資訊
650) this.width=650;" title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M00/6D/B2/wKioL1Vpu1aCxnaEAAAmb73jDg8273.jpg" "519" height="49" />
ping命令:測試網路的連通性
格式:ping [選項] 目標主機
ctrl+c終止測試
650) this.width=650;" title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M00/6D/B6/wKiom1VpucLyGJjHAAEt-H2n_BE907.jpg" "516" height="251" />
跟蹤資料包traceroute
traceroute命令:測試從主機到目的主機之間經過的網路節點
格式:traceroute 目標主機地址
650) this.width=650;" title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M01/6D/B6/wKiom1VpucOzQqKHAABpqfAJ-KE002.jpg" "512" height="74" />
網域名稱解析nslookup
nslookup命令:測試DNS網域名稱解析
格式:nslookup 目標主機地址 [DNS伺服器位址]
650) this.width=650;" title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M02/6D/B6/wKiom1VpucOTQRbKAADeztEPKog461.jpg" "531" height="231" />
設定網路參數的方式
臨時配置——使用命令調整網路參數
簡單,快速,課直接修改運行中的網路參數
一般只適合在調試網路的過程中使用
系統重啟以後,所做的修改將會失效
固定設定——通過設定檔修改網路參數
修改各項網路參數的設定檔
適合對伺服器設定固定參數時使用
需要重載網路服務或者重啟以後才會生效
設定網路介面參數ifconfig
設定網路介面的ip地址,子網路遮罩
格式:ifconfig 介面名 ip地址 [netmask 子網路遮罩]
ifconfig 介面名 ip地址 [/掩碼長度]
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M00/6D/B6/wKiom1VpucPSs0qyAAA9WPzU4O4410.jpg" width="481" height="48" />
禁用或者重新啟用網卡
ifconfig 網路介面 up
ifconfig 網路介面 down
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M00/6D/B2/wKioL1Vpu1nh4izUAAA3nGGDzfY962.jpg" width="472" height="48" />
設定虛擬網路介面
格式:ifconfig 介面名:序號 ip地址
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M00/6D/B6/wKiom1VpucTTPAo6AAA9Qu30Fyo824.jpg" width="479" height="48" />
設定路由記錄route
刪除路由表中的預設閘道記錄
route del default gw ip地址
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M01/6D/B2/wKioL1Vpu1mxoqusAAB5JhJZkSA877.jpg" width="482" height="104" />
向路由表中添加的預設閘道記錄
route add default gw ip地址
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M01/6D/B6/wKiom1VpucSA34pPAABz4gf2dtU347.jpg" width="477" height="101" />
添加到指定網段的路由記錄
route add –net 網段地址 gw ip地址
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M00/6D/B6/wKiom1VpucSz7EznAACTEMHsfMY572.jpg" width="476" height="122" />
刪除到指定網段的路由記錄
route del –net 網段地址 gw ip地址
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M01/6D/B6/wKiom1VpucXBtCAhAACEgqHigE0342.jpg" width="477" height="118" />
編寫shell指令碼,添加路由記錄
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M02/6D/B2/wKioL1Vpu1uxGd8RAAAoZe0v7oc049.jpg" width="368" height="36" />
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M00/6D/B2/wKioL1Vpu1vgtJjiAABGr9z8AVk281.jpg" width="479" height="80" />
為指令碼添加可執行許可權
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M02/6D/B6/wKiom1Vpucag5Z3-AABQjUION5w469.jpg" width="474" height="57" />
編輯/etc/rc.local檔案,重啟後路由記錄自動添加
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M00/6D/B6/wKiom1VpucaiYcWCAAAvP_48pFk260.jpg" width="463" height="38" />
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M01/6D/B2/wKioL1Vpu1yjFBvnAACLAFAD9SY232.jpg" width="466" height="150" />
網路介面設定檔
/etc/sysocnfig/network-scripts/目錄下的
ifcfg-eth0:第1塊乙太網路卡的設定檔
ifcfg-eth1:第2塊乙太網路卡的設定檔
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M02/6D/B2/wKioL1Vpu1zTWae5AACAXMfIZFc857.jpg" width="472" height="77" />
啟用、禁用網路介面配置
重啟network:網路服務
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M00/6D/B2/wKioL1Vpu12QTurSAABdZ_z0JvQ165.jpg" width="482" height="82" />
禁用、啟用網路介面
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M01/6D/B6/wKiom1VpuciThFdhAABOrIdF8xY781.jpg" width="487" height="56" />
主機名稱設定檔
/etc/sysconfig/network檔案
用途:儲存全域網路設定,主要包括主機名稱資訊
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M01/6D/B2/wKioL1Vpu13CAnduAABCzqhFJUU041.jpg" width="493" height="51" />
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M02/6D/B2/wKioL1Vpu16y4qpWAABeNufkaPU108.jpg" width="491" height="112" />
網域名稱解析設定檔
/etc/resolv.conf檔案
用途:儲存本機需要使用的DNS伺服器的IP地址
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M00/6D/B2/wKioL1Vpu16wxzJBAABCqENyz-I679.jpg" width="491" height="57" />
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M01/6D/B2/wKioL1Vpu1_RKJJDAADcpFAmxqk250.jpg" width="505" height="240" />
本地主機對應檔
/etc/hosts檔案
用途:儲存主機名稱與Ip地址的映射記錄
650) this.width=650;" title="image" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M02/6D/B2/wKioL1Vpu2DBAjnmAABvMBV9IWU998.jpg" width="502" height="65" />
hosts檔案和DNS伺服器的比較
預設情況下,系統首先從hosts檔案尋找解析記錄
hosts檔案只對當前的主機有效
hosts檔案可減少DNS查詢過程,從而加快訪問速度
linux基礎網路設定