常见软件代理设置
为了网络安全,在公司内网中一般是不能直连互联网,一般会通过一些代理的方式来访问外网。
常见软件一般都是通过http代理来访问
windows
cmd
1 2 3 4 5 6
| #设置代理 (只针对当前terminal有效) set http_proxy=http://xxx.xxx.xxx.xxx:xxx set https_proxy=http://xxx.xxx.xxx.xxx:xxx
#取消代理 一般来说直接关闭cmd即可
|
全局
设置系统环境变量
linux(类unix)
terminal
1 2
| export http_proxy="http://xxx.xxx.xxx.xxx:xxx" export https_proxy="https://xxx.xxx.xxx.xxx:xxx"
|
全局
vi /etc/profile
针对全部用户
vi ~/.bashrc
针对当前用户
1 2 3
| export http_proxy="http://xxx.xxx.xxx.xxx:xxx" https_proxy="https://xxx.xxx.xxx.xxx:xxx" export https_proxy
|
npm
1 2 3 4 5 6 7
| 设置代理 npm config set proxy http://username:password@xxx.xxx.xxx.xxx:xxx npm config set proxy http://xxx.xxx.xxx.xxx:xxx npm config set https-proxy http://xxx.xxx.xxx.xxx:xxx
npm config delete proxy npm config delete https-proxy
|
git
1 2 3 4 5 6
| git config --global http.proxy xxx.xxx.xxx.xxx:xxx git config --global https.proxy xxx.xxx.xxx.xxx:xxx
git config --global --unset http.proxy
|
docker
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| cat >/etc/systemd/system/docker.service.d/http_proxy.conf << EOF
[Service] Environment="HTTP_PROXY=http://xxx.xxx.xxx.xxx:xxx/" Environment="HTTPS_PROXY=http://xxx.xxx.xxx.xxx:xxx/" Environment="NO_PROXY=localhost,127.0.0.0/8,docker-registry.somecorporation.com"
cat >/etc/docker/daemon.json << EOF
{ "registry-mirrors": ["https://h3j9xv2v.mirror.aliyuncs.com"] }
systemctl daemon-reload systemctl restart docker
|
双网卡设置
1 2 3 4 5
| 可以通过route来选择是否网卡 设置所有网络走 192.168.43.1 网关, metric 10 是设置优先级别 route add -p 0.0.0.0 mask 0.0.0.0 192.168.43.1 metric 10 设置访问10网段的网络走10.130.142.1网关 route add -p 10.0.0.0 mask 255.0.0.0 10.130.142.1 metric 20
|
端口保留
windows端口保留
通过端口保留,应用程序可以阻止一定范围内的端口在通配绑定期间被分配。然而,保留某一端口范围并不会阻止应用程序在保留的范围内执行特定的绑定(请求使用特定端口)。保留端口范围时,所选择的端口号连续范围必须是从 1025 到 MaxUserPort 设置值(默认值为 5000)或从 49152 到 65535。多个客户端应用程序可保留相同的范围。取消保留(删除保留)时,Windows 套接字会删除它找到的第一个完全包含在取消保留请求内的条目。
还可以执行以下操作,通过注册表来指定保留端口的范围:
步骤 |
操作 |
1. |
单击开始,再单击运行,键入 regedit.exe,然后单击确定。 |
2. |
找到而后单击以下注册表子项:HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters |
3. |
在编辑菜单上,指向新建,然后单击多字符串值。 |
4. |
键入 ReservedPorts,然后按 ENTER。 |
5. |
双击 ReservedPorts 值,使用以下语法键入端口范围:x-y要指定单个端口,请对 x 和 y 使用相同的值。例如,要指定端口 4000,请键入 4000-4000。 |
6. |
单击确定。 |
7. |
退出注册表编辑器。 |
reference: https://blog.csdn.net/sforiz/article/details/79926256
linux端口保留
使用net.ipv4.ip_local_port_range
1 2 3 4
| # vi /etc/sysctl.conf 在文件末尾增加以下内容: net.ipv4.ip_local_port_range = 5000 65000 # /sbin/sysctl -p
|
使用文件限制
1 2 3 4
| $ cat /proc/sys/net/ipv4/ip_local_port_range 32000 61000 $ cat /proc/sys/net/ipv4/ip_local_reserved_ports 8080,9148
|
reference: https://blog.csdn.net/mergerly/article/details/44944557