常用命令

  • 端口号占用情况

    • 某个端口:netstat -ano |findstr 8080
    • 所有端口占用情况:netstat -ano

      网络

      域名问题

  • 修改本地端口和域名的对应信息(即host文件)

    1. - 文件地址
    2. - ![image.png](https://cdn.nlark.com/yuque/0/2020/png/710889/1598937050649-823ab020-3d62-43ad-866b-537d662f5605.png#crop=0&crop=0&crop=1&crop=1&height=92&id=qqt91&margin=%5Bobject%20Object%5D&name=image.png&originHeight=184&originWidth=934&originalType=binary&ratio=1&rotation=0&showTitle=false&size=21298&status=done&style=none&title=&width=467)

    内网穿透

  • 博客

  • 准备一台公网服务器
    • nginx.conf添加内容 ```nginx

      用nginx创建代理,如果有人访问http://x.xx.xxx

      nginx会把请求转发给tunnel,这个tunnel指的就是这台公网服务器

      端口号是7689,后面会用这个跟内网来进行通信

      upstream tunnel { server 127.0.0.1:7689; }

server { listen 80; server_name x.xx.xxx;

location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off;

  1. proxy_pass http://tunnel;

} }

  1. - 内网服务器
  2. - 使用ssh打开一个通道
  3. - ssh -vnNT -R 服务器端口:localhost:本地端口 服务器用户名@服务器 IP 地址
  4. - **如:**ssh -vnNT -R 7689:localhost:8000 root@47.45.14.12
  5. - 7689指的是公网服务器的端口,localhost:8000是内网服务器的ip端口
  6. - root是公网服务器的用户,47.45.14.12是公网服务器的ip
  7. - **self:**ssh -vnNT -R 7788:localhost:3306 root@47.106.103.145
  8. - 所以:
  9. - 当我们访问[http://x.xx.xxx](https://link.zhihu.com/?target=http%3A//x.xx.xxx)的时候,得到的响应是你内网服务器上的服务(会把请求转到服务器上的7968端口,这个端口跟我们内网环境上的8000端口是连接到一块的)
  10. - 注意
  11. - 内网映射自己公网IP云服务器搭建用nginxSSH都可以,可以留意一些内存溢出情况加个脚本自动重启下执行。
  12. - 内网映射无公网IP环境,可以直接通过nat123将本地内网IP端口映射到自己域名来外网访问。
  13. <a name="1VDuV"></a>
  14. # 小功能
  15. <a name="NTOY9"></a>
  16. ## 管理员cmd
  17. - 添加管理员cmd
  18. - 新建文本文件,命名cmdCreate.reg(注册表文件)
  19. - 双击运行
  20. - 如果出现编码问题,就把编码改成**ANSI**
  21. - 创建代码
  22. ```shell
  23. Windows Registry Editor Version 5.00
  24. ; Created by: Shawn Brink
  25. ; http://www.sevenforums.com
  26. ; Tutorial: http://www.sevenforums.com/tutorials/47415-open-command-window-here-administrator.html
  27. [-HKEY_CLASSES_ROOT\Directory\shell\runas]
  28. [HKEY_CLASSES_ROOT\Directory\shell\runas]
  29. @="命令行(管理员)"
  30. "HasLUAShield"=""
  31. [HKEY_CLASSES_ROOT\Directory\shell\runas\command]
  32. @="cmd.exe /s /k pushd \"%V\""
  33. [-HKEY_CLASSES_ROOT\Directory\Background\shell\runas]
  34. [HKEY_CLASSES_ROOT\Directory\Background\shell\runas]
  35. @="命令行(管理员)"
  36. "HasLUAShield"=""
  37. [HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command]
  38. @="cmd.exe /s /k pushd \"%V\""
  39. [-HKEY_CLASSES_ROOT\Drive\shell\runas]
  40. [HKEY_CLASSES_ROOT\Drive\shell\runas]
  41. @="命令行(管理员)"
  42. "HasLUAShield"=""
  43. [HKEY_CLASSES_ROOT\Drive\shell\runas\command]
  44. @="cmd.exe /s /k pushd \"%V\""
  • 取消功能 ```shell Windows Registry Editor Version 5.00

; Created by: Shawn Brink

; http://www.sevenforums.com

; Tutorial: http://www.sevenforums.com/tutorials/47415-open-command-window-here-administrator.html

[-HKEY_CLASSES_ROOT\Directory\shell\runas]

[-HKEY_CLASSES_ROOT\Directory\Background\shell\runas]

[-HKEY_CLASSES_ROOT\Drive\shell\runas] ```