ubuntu下網絡查看的相關命令參考

根據IP查電腦名

nmblookup -A IP地址

查看當前IP地址

ifconfig eth0 |awk '/inet/ {split($2,x,":");print x[2]}'

查看當前外網的IP地址

w3m -no-cookie -dump www.123cha.com|grep -o '[0-9]/{1,3/}/.[0-9]/{1,3/}/.[0-9]/{1,3/}/.[0-9]/{1,3/}'
w3m -no-cookie -dump ip.loveroot.com|grep -o '[0-9]/{1,3/}/.[0-9]/{1,3/}/.[0-9]/{1,3/}/.[0-9]/{1,3/}'

查看當前監聽80端口的程序

lsof -i :80

查看當前網卡的物理地址

ifconfig eth0 | head -1 | awk '{print $5}'

同一個網卡增加第二個IP地址

#在網卡eth0上增加一個1.2.3.4的IP:
sudo ifconfig eth0:0 1.2.3.4 netmask 255.255.255.0
#刪除增加的IP:
sudo ifconfig eth0:0 down

立即讓網絡支持nat

echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
sudo iptables -t nat -I POSTROUTING -j MASQUERADE

查看路由信息

netstat -rn
sudo route -n

手工增加一條路由

sudo route add -net 192.168.0.0 netmask 255.255.255.0 gw 172.16.0.1

手工刪除一條路由

sudo route del -net 192.168.0.0 netmask 255.255.255.0 gw 172.16.0.1



修改網卡MAC地址的方法

sudo ifconfig eth0 down #關閉網卡
sudo ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE #然後改地址
sudo ifconfig eth0 up #然後啓動網卡

永久改地址方法

sudo gedit /etc/network/interfaces

在 iface eth0 inet static 後面添加一行:

pre-up ifconfig eth0 hw ether 01:01:01:01:01:01

配置文件應該像如下

iface eth0 inet static
pre-up ifconfig eth0 hw ether 01:01:01:01:01:01
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1

最後是 logout 或者reboot

統計當前IP連接的個數

netstat -na|grep ESTABLISHED|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -r -n
netstat -na|grep SYN|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -r -n

統計當前20000個IP包中大於100個IP包的IP地址

tcpdump -tnn -c 20000 -i eth0 | awk -F "." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr | awk ' $1 > 100 '

屏蔽IPV6

echo "blacklist ipv6" | sudo tee /etc/modprobe.d/blacklist-ipv6

察看當前網絡連接狀況以及程序

sudo netstat -atnp

查看網絡連接狀態

netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'

查看當前系統所有的監聽端口

nc -zv localhost 1-65535

查看網絡的當前流量

#安裝 ethstatus 軟件
sudo apt-get install ethstatus
#查看 ADSL 的速度
sudo ethstatus -i ppp0
#查看 網卡 的速度
sudo ethstatus -i eth0
#或安裝 bwm-ng 
sudo apt-get install bwm-ng
#查看當前網絡流量
bwm-ng

查看域名的註冊備案情況

whois baidu.cn

查看到某一個域名的路由情況

tracepath baidu.cn

重新從服務器獲得IP地址

sudo dhclient

從當前頁面開始鏡像整個網站到本地

wget -r -p -np -k http://www.21cn.com
· -r:在本機建立服務器端目錄結構;
· -p: 下載顯示HTML文件的所有圖片;
· -np:只下載目標站點指定目錄及其子目錄的內容;
· -k: 轉換非相對鏈接爲相對鏈接。

如何多線程下載

sudo apt-get install axel
axel -n 5 <a title="" [此鏈接已破解]"="" href="http://xxx.xxx.xxx.xxx/xxx.zip" _xhe_href="http://xxx.xxx.xxx.xxx/xxx.zip" style="text-decoration: none; color: rgb(86, 96, 83);">http://xxx.xxx.xxx.xxx/xxx.zip
或者
lftp -c "pget -n 5 <a title="" [此鏈接已破解]"="" href="http://xxx.xxx.xxx.xxx/xxx.zip" _xhe_href="http://xxx.xxx.xxx.xxx/xxx.zip" style="text-decoration: none; color: rgb(86, 96, 83);">http://xxx.xxx.xxx.xxx/xxx.zip“

如何查看HTTP頭

w3m -dump_head http://www.example.com
或 curl --head http://www.example.c
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章