Ubuntu查看当前IP地址

【转】 Ubuntu查看当前IP地址
2010-05-19 22:33
转载自 hualaier
最终编辑 hualaier
ifconfig eth0 |awk '/inet/ {split($2,x,":");print x[2]}'
截图:

网络

根据IP查网卡地址

arping IP地址


根据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 http://xxx.xxx.xxx.xxx/xxx.zip
或者
lftp -c "pget -n 5 http://xxx.xxx.xxx.xxx/xxx.zip“


如何查看HTTP头


w3m -dump_head http://www.example.com
或 curl --head http://www.example.com


快速使用http方式共享目录


#进入需要共享的目录后运行: 
python -m SimpleHTTPServer
#其它电脑使用http://ip:8000 来访问
#自定义端口为8080:
python -m SimpleHTTPServer 8080
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值