clash的搭建教程

没啊办法,翻墙翻墙还是翻墙。 上游有若干 trojian 、v2ray 、sock5 、http各种各样的代理,这样多种的选择,那么就装一个 clash 客户端就可以全接管了。 说下我们的做法:找个小Linux做旁路由,DNS和网关都设置在这台机器上,局域网内的机器都通过这台上网。 我们用到的是 clash 的 Tproxy redir-host 和 udp-proxy 模式,这种模式比较强大。用就用最强大的。 安装很简单,操作系统 centos 或者 ubuntu 都行,项目地址: https://github.com/Dreamacro/clash 说明书: https://lancellc.gitbook.io/clash/clash-config-file/proxy-groups/load-balance 首先下载二进制文件,现在版本是 v1.7.1,解压后放到 /usr/local/bin 目录下 wget https://github.com/Dreamacro/clash/releases/download/v1.7.1/clash-linux-amd64-v1.7.1.gz gzip -d clash-linux-amd64-v1.7.1.gz chmod 755 clash-linux-amd64-v1.7.1 mv clash-linux-amd64-v1.7.1 /usr/local/bin 然后生成 clash.service cat << EOF >> /etc/systemd/system/clash.service [Unit] Description=clash service After=network.target [Service] Type=simple User=root ExecStart=/usr/local/bin/clash-linux-amd64-v1.7.1 Restart=on-failure # or always, on-abort, etc [Install] WantedBy=multi-user.target EOF 然后最重要的,就是配置文件了 我这里这个旁路由的设备 IP 地址是 192.168.2.2,网卡设备是 enp2s0 ...

2021年11月08日 · 3 分钟 · 474 字 · 八戒

onedev构建一个实际java spring应用

上篇简单介绍了 onedev ,这篇我们具体拿个 java spring 的项目来实际编译一下 首先必须确认环境: onedev 和 agent 都是用 root 安装运行的,然后已经安装了 docker,且 selinux 设置为 disabled,否则会出权限麻烦。 我们用的例子是 spring 的 petclinic,正常的 build 的步骤如下: git clone https://github.com/spring-projects/spring-petclinic.git cd spring-petclinic ./mvnw package 我们首先在 onedev 的 projects 新建一个项目 spring-boot 然后到 clone 下来的源代码目录下 cd spring-petclinic git init git add . git commit -m "Spring boot demo project" git remote add origin http://192.168.86.101:6610/spring-boot git push --set-upstream origin master 这样就可以在 spring-boot 里看到代码了 然后看上图,有个紫色灯泡,Enable build support by adding.onedev-buildspec.yml,点那个链接 ...

2021年11月08日 · 1 分钟 · 176 字 · 八戒

n2n一种peer to peer的VPN的使用

vpn的搭建一直是一个难解的题目,openvpn、ipsec、tinc 都在用,都不够简洁。 n2n 是一种 peer to peer 端到端的 vpn,搭建起来非常简单方便。必备利器 首先了解一下概念 n2n 的 vpn 分为两种角色,Supernode 超级节点和 Edgenode 边缘节点。 很简单,Supernode 最好是公网地址,需要开放端口供其它节点连接上来;剩余的 Edgenode 可以没有公网地址,各个 Edgenode 边缘节点之间会尝试绕过 Supernode 直接连接。这大大提高了节点之间通讯的效率。通讯是加密的,非常安全。 安装的话完全不用安装,直接一个命令就搞定了。 https://github.com/ntop/n2n 弄出两个可执行文件 supernode 和 edge 就好了 超级节点: /usr/local/bin/supernode -p 11111 -v 边缘节点: /usr/local/bin/edge -d n2n0 -c ThisisaSecret2012 -k Fuck2020 -a 192.168.0.2 -l 41.22.59.112:11111 -f 参数解释: -d 生成的虚拟网卡的命名 -c community-name 同一组vpn节点的密码。大家看到启动 supernode 的时候没有任何参数,supdernode 只负责转发,且支持多组不同的 vpn。这里就是用来区分不同的 vpn 组的。 -k 密码,节点之间通讯是用的 twofish 加密算法 -a 节点的ip -l supernode的ip和端口 -f 放到后台 daemon 执行 这样就建立好了,系统中会多出一张 n2n0 的网卡。 ...

2021年11月05日 · 1 分钟 · 77 字 · 八戒

一站式Git软件onedev的安装使用

其实一直在用 github、gitlab、jenkins,但是 github 时不时的抽风, gitlab 的 runner 套 Docker in docker 的方法委实很难用。 所以 CI/CD 这一块反倒挺喜欢阿里云效这种简便易行的。但确实找不到其他合适且类似的软件。 从 V2EX 上看到一个老哥发的 onedev,是一个一站式的开源软件,这不就试试先 以 centos7 为例,安装过程如下: 一、安装 java 1.8 版本 rpm -ivh jdk-8u201-linux-x64.rpm 二、安装 git 高版本 缺省 centos7 和 epel 带的 git 版本太低,不符合要求,得加个新的源装新版本 yum -y install https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm yum -y install git curl 三、安装配置 onedev https://github.com/theonedev/onedev 下载压缩包,然后解压运行 bin/server.sh start ,很简洁,不错! 运行完打开 http://192.168.86.101:6610 进行初始配置,就两步就 ok 了。 三、例子 我们是要在正式生产环境用的,所以在 projects 新建一个项目 spring-boot,以 spring-petclinic 为例: 然后到源代码目录下 ...

2021年11月05日 · 1 分钟 · 117 字 · 八戒

Haproxy的Zero downtime重启如何做

Nginx 可以用 kill -HUP 来重启,不会丢失已建连接。Haproxy 如何做才能做到 zero downtime 无缝重载呢? 做法如下: 一、配置 编译harpoxy的时候带上参数 USE_SYSTEMD,选择 Haproxy 1.8 以上版本 make TARGET=linux2628 USE_GETADDRINFO=1 USE_ZLIB=1 USE_REGPARM=1 USE_OPENSSL=1 \ USE_SYSTEMD=1 USE_PCRE=1 USE_PCRE_JIT=1 USE_NS=1 make install Haproxy无缝重载技术: 旧进程当前管理的连接根据 file descriptor 文件描述符通过 socket 套接字传输到新进程。 在这个过程中,文件socket(unix socket)的连接没有断开。 新进程在充当 master-worker 主工作者的同时执行此任务。 综上所述,通过使用unix socket来维护连接状态并在旧进程和新进程之间传递,防止了连接丢失。 haproxy 的运行使用 Systemd 重载,使用 -Ws 方式。 (此外,在构建时必须启用 USE_SYSTEMD) -D : start as a daemon. The process detaches from the current terminal after forking, and errors are not reported anymore in the terminal. It is equivalent to the "daemon" keyword in the "global" section of the configuration. It is recommended to always force it in any init script so that a faulty configuration doesn't prevent the system from booting. -W : master-worker mode. It is equivalent to the "master-worker" keyword in the "global" section of the configuration. This mode will launch a "master" which will monitor the "workers". Using this mode, you can reload HAProxy directly by sending a SIGUSR2 signal to the master. The master-worker mode is compatible either with the foreground or daemon mode. It is recommended to use this mode with multiprocess and systemd. -Ws : master-worker mode with support of `notify` type of systemd service. This option is only available when HAProxy was built with `USE_SYSTEMD` build option enabled. 具体的启动脚本:/etc/systemd/system/haproxy.service ...

2021年11月04日 · 2 分钟 · 389 字 · 八戒

alphine镜像的使用技巧

用 alphine 镜像的一些常用技巧: 会随时增加: 一、修改源,用国外的源非常慢,替换成国内的中科大源 sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories 二、更新apk库 apk update 三、安装软件 #安装telnet apk add busybox-extras #安装curl apk add curl #安装时间组件 apk add tzdata #更新并且安装软件 apk add --update tzdata 四、进入容器一步执行换源、更新、安装 sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && apk update && apk add curl && apk add busybox-extras 五、解决缺少glibc库的问题 如果不ln会报错,原因是缺少glibc库!!!解决方法如下: RUN mkdir /lib64 && \ ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 六、一些调试的CMD CMD ["/bin/bash", "-c", "while true; do echo hi; sleep 10; done"] kubectl run curlpod --image=radial/busyboxplus:curl --command -- /bin/sh -c "while true; do echo hi; sleep 10; done" 七、pod的等待技巧 这儿里启动正式的pod之前,先临时起了两个容器等待其他服务的完成 ...

2021年11月04日 · 1 分钟 · 143 字 · 八戒

alphine镜像中timezone的设定

我们都喜欢用 alphine 的镜像做底包,来生产自己的镜像 alphine 的底包的时间设定就非常重要了 直接给出 Dockerfile FROM alpine:3.12 # latest certs RUN apk add ca-certificates --no-cache && update-ca-certificates # timezone support ENV TZ=Asia/Shanghai RUN apk add --update tzdata --no-cache &&\ cp /usr/share/zoneinfo/${TZ} /etc/localtime &&\ echo $TZ > /etc/timezone # install chrony and place default conf which can be overridden with volume RUN apk add --no-cache chrony && mkdir -p /etc/chrony COPY chrony.conf /etc/chrony/. # port exposed EXPOSE 123/udp # start CMD [ "/usr/sbin/chronyd", "-d", "-s"] 时间设定重要的就是下面这几行 ...

2021年11月03日 · 1 分钟 · 105 字 · 八戒

生产环境Proxmox 7.02的安装和配置

其实我们的生产环境一直是 KVM ,然后用 shell 脚本控制虚机的生成,也是用到了 Cloud-init 的标准镜像。 听说 Proxmox 也很不错,于是想看看能否也在生产环境中用上 如果在生产环境中用,必须要让 proxmox 支持 cloud-init ,否则无意义,下面也说一下跑在生产的注意事项 首先我们用光盘安装: 然后第一个注意的地方就是硬盘,选 Options 后: 会冒出一堆选项,公司的生产环境,服务器如果没有 raid 卡是很奇怪的,所以 zfs 反而不是标配,因为我们会事先在 raid 卡上划分好硬盘,生产环境基本必然是 raid10 ,接下来就是 ext4 和 xfs 二选一了,八戒选 ext4 ,因为坏了好修理,xfs_repair 用起来相当龟毛: 那么,选定了 ext4 ,接下来就比较重要了 hdsize 1116.0 ,单位是G,这个是自动收集上来的,不用改 swapsize,交换分区大小,这个给 8 G(最大8G) maxroot,这个分区是第一个分区,存放 iso 和 template 的,需要给够,100 G minfree,第一个分区最小留多大,给 10 G(缺省16G) maxvz,这个分区是第二个分区,存放实际的虚机文件,全都用上,什么也不填写 然后继续,国家选 china,Hostname 填写 proxmox-168-86-103.local,再填写好其他信息,就安装成功了。 打开网页,我们可以看到一个 local,100G,对应上面的 maxroot 然后 local-lvm ,就是剩余放虚机的空间 ...

2021年11月03日 · 2 分钟 · 300 字 · 八戒

k8s中nginx ingress的性能优化

kubernetes 中 nginx ingress 的优化分两部分 一、系统sysctl部分优化 首先是对nginx启动前的系统性能进行优化,这部分调整网络的缓冲区,减小闲置 socket 关闭的时间 以阿里 ACK 为例,我们可以编辑 deployments 的 nginx-ingress-controller initContainers: - command: - /bin/sh - -c - | mount -o remount rw /proc/sys sysctl -w net.core.somaxconn=65535 sysctl -w net.ipv4.ip_local_port_range="1024 65535" sysctl -w net.ipv4.tcp_tw_reuse=1 sysctl -w fs.file-max=1048576 sysctl -w net.ipv4.tcp_keepalive_time = 300 sysctl -w net.ipv4.tcp_keepalive_probes = 5 sysctl -w net.ipv4.tcp_keepalive_intvl = 15 二、nginx ingress 参数优化 大家制动,nginx ingree 其实是做为一个中间代理,所以上下游的socket参数也需要优化 ...

2021年11月02日 · 1 分钟 · 122 字 · 八戒

Linux内核sysctl内核参数优化

这篇是纯配置篇,解释都在配置里了,是生产服务器 sysctl.conf 的配置 ### KERNEL ### # Reboot after 10sec. on kernel panic kernel.panic = 10 ### IMPROVE SYSTEM MEMORY MANAGEMENT ### # Increase size of file handles and inode cache fs.file-max = 2097152 # Insure we always have enough memory vm.min_free_kbytes = 8192 # Do less swapping vm.swappiness = 10 vm.dirty_ratio = 10 vm.dirty_background_ratio = 2 ### GENERAL NETWORK SECURITY OPTIONS ### # Avoid a smurf attack net.ipv4.icmp_echo_ignore_broadcasts = 1 # Turn on protection for bad icmp error messages net.ipv4.icmp_ignore_bogus_error_responses = 1 # Turn on syncookies for SYN flood attack protection net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_max_syn_backlog = 8192 # Turn on timestamping net.ipv4.tcp_timestamps = 1 # Turn on and log spoofed, source routed, and redirect packets net.ipv4.conf.all.log_martians = 1 net.ipv4.conf.default.log_martians = 1 # No source routed packets here net.ipv4.conf.all.accept_source_route = 0 net.ipv4.conf.default.accept_source_route = 0 # Turn on reverse path filtering net.ipv4.conf.all.rp_filter = 1 net.ipv4.conf.default.rp_filter = 1 # Make sure no one can alter the routing tables net.ipv4.conf.all.accept_redirects = 0 net.ipv4.conf.default.accept_redirects = 0 net.ipv4.conf.all.secure_redirects = 0 net.ipv4.conf.default.secure_redirects = 0 # Don't act as a router net.ipv4.ip_forward = 0 net.ipv4.conf.all.send_redirects = 0 net.ipv4.conf.default.send_redirects = 0 # Number of times SYNACKs for passive TCP connection. net.ipv4.tcp_synack_retries = 2 # Allowed local port range net.ipv4.ip_local_port_range = 1024 65000 # Protect Against TCP Time-Wait net.ipv4.tcp_rfc1337 = 1 # Decrease the time default value for tcp_fin_timeout connection net.ipv4.tcp_fin_timeout = 15 # Decrease the time default value for connections to keep alive net.ipv4.tcp_keepalive_time = 300 net.ipv4.tcp_keepalive_probes = 5 net.ipv4.tcp_keepalive_intvl = 15 # This means that the keepalive process waits 300 seconds for socket # activity before sending the first keepalive probe, and then resend # it every 15 seconds. If no ACK response is received for 5 consecutive # times (75s in this case), the connection is marked as broken. ### TUNING NETWORK PERFORMANCE ### # Disable IPv6 net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 # Default Socket Receive Buffer net.core.rmem_default = 31457280 # Maximum Socket Receive Buffer net.core.rmem_max = 12582912 # Default Socket Send Buffer net.core.wmem_default = 31457280 # Maximum Socket Send Buffer net.core.wmem_max = 12582912 # Increase number of incoming connections net.core.somaxconn = 5000 # Increase number of incoming connections backlog net.core.netdev_max_backlog = 65536 # Enable TCP window scaling net.ipv4.tcp_window_scaling = 1 # Increase the maximum amount of option memory buffers net.core.optmem_max = 25165824 # Increase the maximum total buffer-space allocatable # This is measured in units of pages (4096 bytes) net.ipv4.tcp_mem = 65536 131072 262144 net.ipv4.udp_mem = 65536 131072 262144 # Increase the read-buffer space allocatable net.ipv4.tcp_rmem = 8192 87380 16777216 net.ipv4.udp_rmem_min = 16384 # Increase the write-buffer-space allocatable net.ipv4.tcp_wmem = 8192 65536 16777216 net.ipv4.udp_wmem_min = 16384 # Increase the tcp-time-wait buckets pool size to prevent simple DOS attacks net.ipv4.tcp_max_tw_buckets = 1800000 # TIME_WAIT socket policy # Note: if both enabled then disable # net.ipv4.tcp_timestamps for servers # behind NAT to prevent dropped incoming connections #net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_tw_reuse = 1 # Enable TCP MTU probing (in case of Jumbo Frames enabled) #net.ipv4.tcp_mtu_probing = 1 # Speedup retrans (Google recommended) net.ipv4.tcp_slow_start_after_idle = 0 net.ipv4.tcp_early_retrans = 1 # Conntrack # 288bytes x 131072 = 37748736 (~38MB) max memory usage #net.netfilter.nf_conntrack_max = 131072 #net.netfilter.nf_conntrack_tcp_loose = 1 #TCP的直接拥塞通告(tcp_ecn)关掉 net.ipv4.tcp_ecn = 0 #路由缓存刷新频率,当一个路由失败后多长时间跳到另一个路由,默认是300。 net.ipv4.route.gc_timeout = 100 #设定系统中最多允许在多少TCP套接字不被关联到任何一个用户文件句柄上。 #如果超过这个数字,没有与用户文件句柄关联的TCP 套接字将立即被复位 #防简单Dos net.ipv4.tcp_max_orphans = 655360 # NOTE: Enable this if machine support it # -- 10gbe tuning from Intel ixgb driver README -- # # turn off selective ACK and timestamps #net.ipv4.tcp_sack = 0 #net.ipv4.tcp_timestamps = 1 ** 注意,net.ipv4.tcp_tw_recycle 不要打开,在 NAT 环境中会出错,而且在 K8S 中也会因 NAT 导致 pod 出错,切记!!!** ...

2021年11月02日 · 3 分钟 · 580 字 · 八戒