参考了https://unix.stackexchange.com/questions/68956/block-network-access-of-a-process ,其中netns是docker在用的方法,配置比较复杂,比较简单的方法是创建专门的group,在iptable增加针对group的限制。
# 新增一个组
groupadd no-lan
# 验证下组
sg no-lan id
| #!/bin/bash | |
| # Get dns-reverse-proxy from https://github.com/notsobad/dns-reverse-proxy | |
| pushd /xxx/dns-reverse-proxy | |
| LAN_DNS=`systemd-resolve --status | grep 'DNS Servers'|cut -d ':' -f2|xargs`:53 | |
| echo "lan dns": $LAN_DNS | |
| sudo ./dns-reverse-proxy\ | |
| -address 0.0.0.0:53 \ | |
| -default 114.114.114.114:53 \ |
| #!/bin/bash | |
| function tab () { | |
| local cmd="" | |
| local cdto="$PWD" | |
| local args="$@" | |
| if [ -d "$1" ]; then | |
| cdto=`cd "$1"; pwd` | |
| args="${@:2}" |
| stages: | |
| - test | |
| workflow: | |
| rules: | |
| - if: $CI_PIPELINE_SOURCE == 'merge_request_event' | |
| pylint-error-only: | |
| stage: test | |
| script: |
参考了https://unix.stackexchange.com/questions/68956/block-network-access-of-a-process ,其中netns是docker在用的方法,配置比较复杂,比较简单的方法是创建专门的group,在iptable增加针对group的限制。
# 新增一个组
groupadd no-lan
# 验证下组
sg no-lan id
| # python http408.py 127.0.0.1 80 25 | |
| import socket | |
| import time | |
| import sys | |
| HOST = sys.argv[1] | |
| PORT = int(sys.argv[2]) | |
| DELAY = int(sys.argv[3]) | |
| s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
| #coding=utf-8 | |
| # https://zh.wikipedia.org/wiki/%E8%92%99%E6%8F%90%E9%9C%8D%E7%88%BE%E5%95%8F%E9%A1%8C | |
| import sys | |
| import random | |
| stay = 0 | |
| change = 0 | |
| MAX_TRY = int(sys.argv[1]) | |
| for i in range(MAX_TRY): |
| docker run -v `pwd`:/data/ -e NODE_TLS_REJECT_UNAUTHORIZED=0 --rm -ti elasticdump/elasticsearch-dump \ | |
| --input=https://user:pass@domain.com/dir/ \ | |
| --input-index=index/type \ | |
| --searchBody="{\"query\":{\"term\":{\"key\": \"xxxx\"}}}" \ | |
| --output=/data/xxx.json \ | |
| --size=1000 \ | |
| --concurrency=5 \ | |
| --type=data |
| # https://askubuntu.com/questions/1049302/wired-ethernet-not-working-ubuntu-18-04 | |
| # ubuntu 18.04 桌面版,发现每次重启后,有线网络是off的状态,需要点击connect,才能连接,查了下,有不少人遇到同样问题,下面这个方法可以解决问题 | |
| service network-manager stop | |
| rm /var/lib/NetworkManager/NetworkManager.state | |
| service network-manager start |