LINUX常用網路測試命令

來源:互聯網
上載者:User
1、 ifconfig    可以使用ifconfig命令來配置並查看網路介面的配置情況。
    例如:
  (1) 配置eth0的IP地址, 同時啟用該裝置。
  #ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up
  (2) 配置eth0別名裝置eth0:1的IP地址,並添加路由。
  #ifconfig eth0 192.168.1.3
  #route add –host 192.168.1.3 dev eth0:1
  (3) 啟用裝置。
  #ifconfig eth0 up
  (4) 禁用裝置。
  #ifconfig eth0 down
  (5) 查看指定的網路介面的配置。
  #ifconfig eth0
  (6) 查看所有的網路介面配置。
  #ifconfig
2、 route
  可以使用route命令來配置並查看核心路由表的配置情況。
  例如:
  (1) 添加到主機的路由。
  #route add –host 192.168.1.2 dev eth0:0
  #route add –host 10.20.30.148 gw 10.20.30.40
  (2) 添加到網路的路由。
  #route add –net 10.20.30.40 netmask 255.255.255.248 eth0
  #route add –net 10.20.30.48 netmask 255.255.255.248 gw 10.20.30.41
  #route add –net 192.168.1.0/24 eth1
  (3) 添加預設閘道。
  #route add default gw 192.168.1.1
  (4) 查看核心路由表的配置。
  #route
  (5)刪除路由。
  #route del –host 192.168.1.2 dev eth0:0
  #route del –host 10.20.30.148 gw 10.20.30.40
  #route del –net 10.20.30.40 netmask 255.255.255.248 eth0
  #route del –net 10.20.30.48 netmask 255.255.255.248 gw 10.20.30.41
  #route del –net 192.168.1.0/24 eth1
  #route del default gw 192.168.1.1
  對於1和2兩點可使用下面的語句實現:
  Ifconfig eth0 172.16.19.71 netmask 255.255.255.0
  Route 0.0.0.0 gw 172.16.19.254
  Service network restart
3、 traceroute
  可以使用traceroute命令顯示資料包到達目的主機所經過的路由。
  例如:
  #traceroute http://www.sina.com.cn/
4、 ping
  可以使用ping 命令來 測試網路的連通性。
  例如:
  #ping http://www.sina.com.cn/
  #ping –c 4 192.168.1.12
5、 netstat
  可以使用netstat命令來顯示網路狀態資訊。
  例如:
  (1) 顯示網路介面狀態資訊。
  #netstat –i
  (2) 顯示所有監控中的伺服器的Socket和正使用Socket的程式資訊。
  #netstat –lpe
  (3) 顯示核心路由表資訊。
  #netstat –r
  #netstat –nr
  (4) 顯示TCP/UDP傳輸協議的串連狀態。
  #netstat –t
  #netstat –u
6、 hostname
  可以使用hostname命令來更改主機名稱。例如;
  #hostname myhost
7、 arp
  可以使用arp命令來配置並查看arp緩衝。例如:
  (1) 查看arp緩衝。
  #arp
  (2) 添加一個IP地址和MAC地址的對應記錄。
  #arp –s 192.168.33.15 00:60:08:27:CE:B2
  (3) 刪除一個IP地址和MAC地址的對應緩衝記錄。
  #arp –d192.168.33.15

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.