嵌入式爱好者

修改端口号

2022-8-20 15:56| 发布者: hai| 查看: 567| 评论: 0

类目: 知识库  >  LS1012A/LS1043A/LS1046A系列产品     文档编号: 723

端口介绍

在网络技术中,端口(Port)大致有两种意思。一种是指TCP/IP协议中的端口,端口号的范围从0到65535(端口0一般不使用)。比如用于浏览网页服务的80端口,用于mysql服务的3306端口等等。还有一种是物理意义上的端口,比如ADSL Modem、集线器、交换机、路由器用于连接其他网络设备的接口,如RJ-45端口、SC端口等等。

这里主要介绍TCP/IP协议中的端口:

(1)知名端口

知名端口即众所周知的端口号,范围从0到1023;这些端口号一般固定分配给一些服务,比如21端口分配给FTP服务,25端口分配给SMTP(简单邮件传输协议)服务,80端口分配给HTTP服务,135端口分配给RPC(远程过程调用)服务等等。

(2)注册端口

从1024到49151。

它们松散地绑定于一些服务。也就是说有许多服务绑定于这些端口,这些端口同样用于许多其它目的。例如:许多系统处理动态端口从1024左右开始,比如1024端口就是分配给第一个向系统发出申请的程序。在关闭程序进程后,就会释放所占用的端口号

(3)动态端口

从49152到65535。这些端口号一般不固定分配给某个服务,也就是说许多服务都可以使用这些端口。只要运行的程序向系统提出访问网络的申请,那么系统就可以从这些端口号中分配一个供该程序使用。

1.查看有哪些服务在使用端口

root@forlinx:~# sudo netstat -anp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp       0     0 0.0.0.0:80             0.0.0.0:*               LISTEN     476/lighttpd        
tcp       0     0 0.0.0.0:21             0.0.0.0:*               LISTEN     443/vsftpd          
tcp       0     0 127.0.0.53:53           0.0.0.0:*               LISTEN     244/systemd-resolve
tcp       0     0 0.0.0.0:22             0.0.0.0:*               LISTEN     450/sshd            
tcp6       0     0 :::22                   :::*                   LISTEN     450/sshd            
udp       0     0 127.0.0.53:53           0.0.0.0:*                           244/systemd-resolve
udp       0     0 0.0.0.0:69             0.0.0.0:*                           464/in.tftpd        
udp       0     0 0.0.0.0:5353           0.0.0.0:*                           407/avahi-daemon: r
udp       0     0 0.0.0.0:40310           0.0.0.0:*                           407/avahi-daemon: r
udp       0     0 0.0.0.0:4500           0.0.0.0:*                           399/charon          
udp       0     0 0.0.0.0:500             0.0.0.0:*                           399/charon          
udp6       0     0 :::69                   :::*                               464/in.tftpd        
udp6       0     0 :::5353                 :::*                               407/avahi-daemon: r
udp6       0     0 :::4500                 :::*                               399/charon          
udp6       0     0 :::57818               :::*                               407/avahi-daemon: r
udp6       0     0 :::500                 :::*                               399/charon          

注:本次以修改lighttpd为例

2.查看lighttpd服务的配置文件位置

root@forlinx:~# whereis lighttpd
lighttpd: /usr/sbin/lighttpd /usr/lib/lighttpd /etc/lighttpd /usr/share/lighttpd /usr/share/man/man8/lighttpd.8.gz
root@forlinx:~# vi /etc/lighttpd/lighttpd.conf
/**************************************************************************/
server.modules = (
      "mod_access",
      "mod_alias",
      "mod_compress",
      "mod_redirect",
)

server.document-root       = "/usr/share/matrix-gui-2.0/"
server.upload-dirs         = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
server.port                 = 80 //改为81端口  


index-file.names           = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

compress.cache-dir         = "/var/cache/lighttpd/compress/"
compress.filetype           = ( "application/javascript", "text/css", "text/html", "text/plain" )

# default listening port for IPv6 falls back to the IPv4 port
## Use ipv6 if available
#include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
/****************************************************************************/

3.重启板卡:

root@forlinx:~# sudo netstat -anp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp       0     0 0.0.0.0:81             0.0.0.0:*               LISTEN     511/lighttpd        
tcp       0     0 0.0.0.0:21             0.0.0.0:*               LISTEN     490/vsftpd          
tcp       0     0 127.0.0.53:53           0.0.0.0:*               LISTEN     244/systemd-resolve
tcp       0     0 0.0.0.0:22             0.0.0.0:*               LISTEN     486/sshd            
tcp6       0     0 :::22                   :::*                   LISTEN     486/sshd            
udp       0     0 0.0.0.0:500             0.0.0.0:*                           504/charon          
udp       0     0 0.0.0.0:50171           0.0.0.0:*                           453/avahi-daemon: r
udp       0     0 127.0.0.53:53           0.0.0.0:*                           244/systemd-resolve
udp       0     0 0.0.0.0:69             0.0.0.0:*                           507/in.tftpd        
udp       0     0 0.0.0.0:5353           0.0.0.0:*                           453/avahi-daemon: r
udp       0     0 0.0.0.0:4500           0.0.0.0:*                           504/charon          
udp6       0     0 :::500                 :::*                               504/charon          
udp6       0     0 :::69                   :::*                               507/in.tftpd        
udp6       0     0 :::48268               :::*                               453/avahi-daemon: r
udp6       0     0 :::5353                 :::*                               453/avahi-daemon: r
udp6       0     0 :::4500                 :::*                               504/charon          

可以看到Lighttpd端口已改为81


已解决

未解决

只是看看

QQ|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )

GMT+8, 2024-5-3 10:59

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

返回顶部