码迷,mamicode.com
首页 > 其他好文 > 详细

day4

时间:2016-08-10 23:09:14      阅读:239      评论:0      收藏:0      [点我收藏+]

标签:gateway   路由表   以太网   记录   接口   


查看网络接口的命令为ifconfig,常用的选项为“-a”,可以列出所有网络接口的信息。

利用arp -an命令可以查看本机的ARP缓存表,需注意的是ARP缓存表是临时生成的,在查看前需要ping一下其它主机,生成一条ARP缓存记录。

查看路由表命令为route –n。其中有标记“U”为直连路由,“UG”为静态路由。

可以利用netstat –anptu命令,查看本机当前监听的都有哪些端口。可以利用“|”交由grep命令进行筛选。



ifconfig 命令

Interface Configure

ifconfig 网络接口


ifconfig -a 列出所有接口 包括禁用的

ethX:以太网连接

lo:本地回环接口

stiX:ipv6地址网卡接口

fddX:光纤网卡

PPPX:ADSL宽带或VPN连接


查看本机路由表

route 

-n 显示数字地址


[root@localhost ~]# route -n

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.100.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0

169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0

[root@localhost ~]# route 

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.100.0   *               255.255.255.0   U     0      0        0 eth0

link-local      *               255.255.0.0     U     1002   0        0 eth0


arp

-a:列出所有条目

-n:显示数字地址


[root@localhost ~]# arp -an

? (192.168.100.1) at 00:50:56:c0:00:01 [ether] on eth0


netstat命令 Network Statistics

-a显示所有活动连接

-n以数字形式显示

-p显示进程信息

-t、-u查看TCP连接、UDP连接

-r显示路由表


[root@localhost ~]# netstat -anptu|grep ESTABLISHED

tcp        0      0 192.168.100.100:22          192.168.100.1:13593         ESTABLISHED 2504/sshd           

tcp        0     52 192.168.100.100:22          192.168.100.1:10317         ESTABLISHED 2207/sshd     


查看本机路由表

[root@localhost ~]# netstat -rn

Kernel IP routing table

Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface

192.168.100.0   0.0.0.0         255.255.255.0   U         0 0          0 eth0

169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0


查看指定端口是否开启

[root@localhost ~]# netstat -ln|grep :22

tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      

tcp        0      0 :::22                       :::*                        LISTEN  


查看指定服务监听的端口

[root@localhost ~]# netstat -tulnp|grep sshd

tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1945/sshd           

tcp        0      0 127.0.0.1:6010              0.0.0.0:*                   LISTEN      2207/sshd           

tcp        0      0 127.0.0.1:6011              0.0.0.0:*                   LISTEN      2508/sshd           

tcp        0      0 :::22                       :::*                        LISTEN      1945/sshd           

tcp        0      0 ::1:6010                    :::*                        LISTEN      2207/sshd           

tcp        0      0 ::1:6011                    :::*                        LISTEN      2508/sshd        


ping命令 测试网络连接

-c 包个数

-s 包大小


ctrl+c中止测试


追踪路由过程

traceroute

mtr IP地址


测试DNS解析

host 目标主机

nslookup 目标主机


临时配置

技术分享


设置路由记录

技术分享


网卡配置文件

系统服务 /etc/init.d/network

[root@localhost ~]# ll /etc/sysconfig/network-scripts/ifcfg-eth0 

-rw-r--r--. 1 root root 182 8月   9 17:17 /etc/sysconfig/network-scripts/ifcfg-eth0


[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0    设备名

HWADDR=00:0C:29:60:34:B9    MAC地址

TYPE=Ethernet    网络类型

UUID=f162cfbc-8a6d-4ee7-9450-2f12d6c42249    UUID

ONBOOT=yes    随network服务启用

NM_CONTROLLED=yes    

BOOTPROTO=none    或者dhcp、static

IPADDR=192.168.100.100    静态ip地址

NETMASK=255.255.255.0    子网掩码

DNS1=114.114.114.114    DNS


改完后,重启网卡服务


6版本可以关闭NetworkManager服务


主机名配置文件

[root@localhost ~]# vim /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=localhost.localdomain


主机映射文件

[root@localhost ~]# vim /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6


dns配置文件

[root@localhost ~]# ll /etc/resolv.conf 

-rw-r--r--. 1 root root 228 8月   9 17:18 /etc/resolv.conf


静态路由配置文件

vim /etc/sysconfig/network-scripts/route-eth0

本文出自 “A New Start” 博客,转载请与作者联系!

day4

标签:gateway   路由表   以太网   记录   接口   

原文地址:http://finalstart.blog.51cto.com/5591045/1836593

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!