如何查看linux系统的网络接口

如何查看linux系统的网络接口,第1张

方法/步骤

1、进入linux,使用“ cat /etc/services ”命令,可以查看所有服务默认的端口列表信息。

2、使用“netstat”命令,查看正在连接的端口【连接】列表信息。

3、使用“nestat -a”命令,查看所有服务端口【监听、连接】列表信息。

4、套接字的种类除了t(TCP)、u(UDP)之外,还有w(RAW)、x(UNIX)套接字。

5、使用" netstat -ap"查看所有服务端口和对应的程序名称

Router>enable 进入特权模式

Router#configure terminal 进入配置模式

Enter configuration commands, one per line. End with CNTL/Z.

Router(config)#interface e 0/0 进入接口以太0/0

Router(config-if)#ip

Router(config-if)#ip address 192.168.1.1 255.255.255.0 配置IP地址和子网掩码

Router(config-if)#no shutdown 开启端口

%LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up

Router(config-if)#exit退出

Router(config)#ip host xiay 192.168.1.2默认域名指向(可以不配置的)

Router(config)#exit退出

Router#show interfaces e 0/0查看以太0/0信息

Ethernet0/0 is up, line protocol is up开启端口

Hardware is Lance, address is 000C.4198.5973 (bia 000C.4198.5973)MAC地址

Internet address is 192.168.1.1/24IP和掩码

MTU 1500 bytes, BW 10000 Kbit, DLY 1000 usec, rely 255/255, load 1/255

Encapsulation ARPA, loopback not set, keepalive set (10 sec)

ARP type: ARPA, ARP Timeout 04:00:00

Last input 00:00:00, output 00:00:00, output hang never

Last clearing of show interface counters never

Queueing strategy: fifo

Output queue 0/40, 0 dropsinput queue 0/75, 0 drops

5 minute input rate 1000 bits/sec, 2 packets/sec

5 minute output rate 1000 bits/sec, 2 packets/sec

0 packets input, 0 bytes, 0 no buffer

Received 0 broadcasts, 0 runts, 0 giants, 0 throttles

0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort

0 input packets with dribble condition detected

0 packets output, 0 bytes, 0 underruns

0 output errors, 0 collisions, 0 interface resets

0 babbles, 0 late collision, 0 deferred

0 lost carrier, 0 no carrier

0 output buffer failures, 0 output buffers swapped out

Router#ping 192.168.1.2pingIP地址

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms通了

Router#ping xiayping 域名(就是刚才定向的那个)

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms通了

Router#copy startup-config tftp 拷贝我的配置文件到tftp

Address or name of remote host []?xiay拷贝到这(也可以输入IP)

Destination filename []?1保存文件名

No NVRAM configuration present失败

Router#

Router#show startup-config 检查我的配置 没有

%% Non-volatile configuration memory is not present

Router#copy running-config startup-config 把我ram上的配置copy到nvram上去

Destination filename [startup-config]?

Building configuration...

[OK]

Router#sh startup-config 再查看下 OK东西有了

Current configuration : 677 bytes

!

Version 12.1

service timestamps debug uptime

service timestamps log uptime

no service password-encryption

!

hostname Router

!

!

!

ip subnet-zero

ip host xiay 192.168.1.2

!

!

!

!

!

!

!

!

!

Router#copy startup-config tftp 拷贝 同上

Address or name of remote host []?xiay

Destination filename []?1

!!!!!!!!!!成功了!!!!!!!

[OK]

8390 bytes copied in 7 secs

===================================

boson 行敲出来顺便给你贴上去的 够详细了把 不加分对不起我啊

在Linux中查找服务的端口

方法1:使用grep命令

要使用grep命令在Linux中查找指定服务的默认端口号,只需运行:

$grep<port>/etc/services

例如,要查找SSH服务的默认端口,只需运行:

$grep ssh/etc/services

就这么简单。此命令应该适用于大多数Linux发行版。以下是我的Arch Linux测试机中的示例输出:

ssh 22/tcp

ssh 22/udp

ssh 22/sctp

sshell 614/tcp

sshell 614/udp

netconf-ssh 830/tcp

netconf-ssh 830/udp

sdo-ssh 3897/tcp

sdo-ssh 3897/udp

netconf-ch-ssh 4334/tcp

snmpssh 5161/tcp

snmpssh-trap 5162/tcp

tl1-ssh 6252/tcp

tl1-ssh 6252/udp

ssh-mgmt 17235/tcp

ssh-mgmt 17235/udp

正如你在上面的输出中所看到的,SSH服务的默认端口号是22。

让我们找到Apache Web服务器的端口号。为此,命令是:

$grep http/etc/services

#http://www.iana.org/assignments/port-numbers

http 80/tcp www www-http#WorldWideWeb HTTP

http 80/udp www www-http#HyperText Transfer Protocol

http 80/sctp#HyperText Transfer Protocol

https 443/tcp#http protocol over TLS/SSL

https 443/udp#http protocol over TLS/SSL

https 443/sctp#http protocol over TLS/SSL

gss-http 488/tcp

gss-http 488/udp

webcache 8080/tcp http-alt#WWW caching service

webcache 8080/udp http-alt#WWW caching service

[...]

FTP端口号是什么?这很简单!

$grep ftp/etc/services

ftp-data 20/tcp

ftp-data 20/udp

#21 is registered to ftp,but also used by fsp

ftp 21/tcp

ftp 21/udp fsp fspd

tftp 69/tcp

[...]

方法2:使用getent命令

如你所见,上面的命令显示指定搜索词“ssh”、“http”和“ftp”的所有端口名称和数字。这意味着,你将获得与给定搜索词匹配的所有端口名称的相当长的输出。

但是,你可以使用getent命令精确输出结果,如下所示:

$getent services ssh

ssh 22/tcp

$getent services http

http 80/tcp www www-http

$getent services ftp

ftp 21/tcp

如果你不知道端口名称,但是知道端口号,那么你只需将端口名称替换为数字:

$getent services 80

http 80/tcp

要显示所有端口名称和端口号,只需运行:

$getent services


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/7421840.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-05
下一篇2023-04-05

发表评论

登录后才能评论

评论列表(0条)

    保存