Linux 練習題-4網絡 命令

1、查看當前系統每IP連接數

netstat -an | grep 'ESTABLISHED' | awk '{print $4}' | awk -F ":" '{print $1}' | sort -n | uniq -c

 

2、列出一下服務使用的端口

http

80

https

443

ftp

數據接口:20  

控制接口:21

telnet

23

ssh

22

rsync

873

dns

5352

mysql

3306

grep -Ew"^(http|https|ftp|telnet|ssh|rsync|dns|mysql)" /etc/services

awk --posix '$1~/^(http|https|ftp|telnet|ssh|rsync|dns|mysql)$/{print $0}' /etc/services

awk --posix -F "[ /]+" '$1~/^(http|https|ftp|telnet|ssh|rsync|dns|mysql)$/{print $1,$2}' /etc/services | sort | uniq

 

3、列出Linux系統下常見的幾種文件格式

uname -r #顯示內核名

ls /lib/modules/2.6.32-358.el6.i686/fs  #顯示Linux支持的文件系統

Linux文件系統類型簡介及支持的文件系統彙總

 

4、在linux下,給eth0配置IP,網關和增加路由

IP192.168.10.100  網關 192.168.10.1 

路由: 到網段 10.10.0.0/255.255.255.0 通過ip  192.168.10.2 出去

ifconfig eth0 192.168.10.100 netmask 255.255.255.0

route add default gw 192.168.10.1

route add  -net 10.10.0.0 netmask 255.255.255.0 gw 192.168.10.2

 

6、寫出172.16.0.10/25192.168.10.2/23的掩碼地址、廣播地址和反掩碼

1172.16.0.10/25

掩碼:255.255.255.128     廣播:172.16.0.127     反掩碼:0.0.0.127

2192.168.10.2/23

掩碼:255.255.254.0     廣播:192.168.11.255     反掩碼:0.0.1.255

3、總結

借主機位叫VLSM

假設借了n位,則就有2^n 個網段。以1)爲例。借了1位,2個子網。在將2560-255)按子網數量劃分。則 172.16.0.0是網絡號 172.16.0.127 是廣播

借網絡位叫超網

超網是把許多子網合成一個網段。將IP和掩碼換成2進程相與得到網絡號爲 192.168.10.0。然後主機位全0 --- 主機位全即爲地址段。

 

7、怎麼查某個端口對應的服務

less /etc/services #通過查找

cat /etc/services | grep -w '22'

 

8tcpdump怎麼抓出IP 10.10.0.10  tcp 80 端口的包

tcpdump tcp port 80 and host 10.10.0.10


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章