Cisco路由器上qos的设置

诉求很简单,对客户限速,那么麻烦就很多,怎么限? 先普及一下Cisco的qos知识 单速单桶: 单速单桶模式不允许流量突发,当用户的流量速率小于配置的CIR时,报文被认为是conform;当用户的流量大于CIR时直接被认为是exceed(思科exceed华为violate)。 (图中Tc代表桶里令牌的数量,CBS代表令牌桶的容量即Bc) 如果只配置CIR,不指定Bc,那么默认Bc等于1500bytes或者 CIR数值 / 32 class 100 police 8000 conform-action transmit exceed-action drop class 200 police cir 8000 conform-action transmit exceed-action drop class 300 police 8000 1500 conform-action transmit exceed-action drop class 400 police cir 8000 bc 1500 conform-action transmit exceed-action drop 单速双桶: 支持突发流量,用户的流量会出现三种结果: (图中Tc、Te代表桶里令牌的数量,CBS,EBS代表令牌桶的容量即Bc、Be) 小于或等于CIR(也就是符合CIR) (conform) 大于CIR并小于或等于CIR与Be之和(也就是符合两个桶令牌之和)(exceed) 超过CIR与Be之和(也就是超过两个桶令牌之和)(violate) 如果只配置CIR、Bc,不指定Be,那么默认Be等于1500bytes或者CIR数值 / 32。 class 500 police 8000 1000 conform-action transmit exceed-action set-prec-transmit 1 violate-action drop class 600 police 8000 1000 1300 conform-action transmit exceed-action set-prec-transmit 1 violate-action drop class 700 police cir 8000 bc 1000 be 1300 conform-action transmit exceed-action set-prec-transmit 1 violate-action drop 双速双桶: ...

2024年1月24日

Cisco vrf错误之the feature does not supported

作为一个运维,现在搞起了Ciso的BGP生意 在Cisco3650上定义VRF,结果报错,一头雾水啊,而且对Cisco也不熟悉啊。 #vrf definition mgmt % Feature is not supported 没办法搜Google啊,解决方法如下: sh license right-to-use license right-to-use activate ipservices all reload license right-to-use activate ipservices all acceptEULA reload 最后显示ipservices和lanbase都有就行了 #sh license right-to-use Slot# License name Type Count Period left ---------------------------------------------------------- 1 ipservices permanent N/A Lifetime 1 lanbase permanent N/A Lifetime

2024年1月24日

Mirror 口直通到Kvm中去遇到的几个问题

由于大搞BGP线路,所以在Cisco路由器上Mirror了入口的流量到另外一个端口,供suricata分析用。 在Mirror直通kvm虚机过程中遇到以下问题: Mirror的口是Te口,10G的流量,在宿主机上tcpdump可以看到所有流量,但是在kvm上则断断续续,流量丢失一部分,原因很简单: 流量的聚合和转发未配置好,两条命令解决 brctl setageing br2 0 brctl setfd br2 0 但是,如何在宿主机启动的时候自动执行这两句呢?简单,如果系统是CentOS cat <<EOF>>/sbin/ifup-local #!/bin/bash brctl setageing br2 0 brctl setfd br2 0 EOF chmod 755 /sbin/ifup-local 如果系统是Ubuntu cd /etc/network/if-up.d cat <<EOF>>br3-mirror #!/bin/bash if [ "$IFACE" = br2 ]; then brctl setageing br2 0 brctl setfd br2 0 fi EOF chmod +x br2-mirror 在宿主机上问题解决了,在kvm虚机上又遇到问题,Ubuntu,如果让一个网口启动但没有地址呢? vi /etc/network/interfaces auto ens7 iface ens7 inet manual mtu 1464 up ifconfig ens7 up 注意上面的,ens7就是mirror过来的网口,mtu是因为在cisco做mirror的时候指定了固定的mtu 1464. brctl命令的用法可以参见以下链接: https://www.thegeekstuff.com/2017/06/brctl-bridge/ over.

2024年1月24日

Fail2ban怎么解放并放入白名单

mouse 的服务器连接到了各个网络核心设备,所以采用了很严格的ip限制,port限制,以及fail2ban来阻止非法访问,但是不巧,把自己也给搞到 jail 里去了。 那么怎么解呢? 首先查看封锁情况: fail2ban-client status Status |- Number of jail: 2 `- Jail list: sshd, sshd-ddos 有两个jail,sshd和sshd-ddos 进一步查看: fail2ban-client status sshd 发现自己被屏蔽了。 解封的方法: fail2ban-client set sshd unbanip 103.108.236.5 解封只是临时的,永久放入白名单最靠谱: vi /etc/fail2ban/jail.conf ignoreip = 103.108.236.5/32 重启fail2ban systemctl restart fail2ban 这样就ok了。

2024年1月24日

配置一个提供IPv6 tunnel over IPv4的OpenVPN服务器

先普及一下IPv6 地址。 IPv6 地址大小为 128 位。 首选 IPv6 地址表示法为8组数字用冒号分隔,其中每组是 8 个 16 位部分的十六进制值。IPv6 地址范围从 0000:0000:0000:0000:0000:0000:0000:0000 至 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff。 除此首选格式之外,IPv6 地址还可以用其他两种短格式指定: 省略前导零 通过省略前导零指定 IPv6 地址。 例如,IPv6 地址 1050:0000:0000:0000:0005:0600:300c:326b 可写作 1050:0:0:0:5:600:300c:326b。 双冒号 通过使用双冒号(::)替换一系列零来指定 IPv6 地址。 例如,IPv6 地址 ff06:0:0:0:0:0:0:c3 可写作 ff06::c3。 一个 IP 地址中只可使用一次双冒号。 在一般IPv6网络环境下,一个局域网的子网大小为/64,接口通过NDP协议获得自己的唯一IPv6地址(前64位为子网前缀,后64位一般由接口本身的MAC地址产生) 我们的场景: 服务器的IPV4地址是 1.2.3.4 服务器的IPV6地址是 aaaa:bbbb:cccc:dddd::/64 IPV4和IPV6的地址都在eth0上 VPN分配给客户端的IPV6地址是aaaa:bbbb:cccc:dddd:80::/112,使用的接口是tun0 配置过程如下: 首先修改/etc/sysctl.conf文件 net.ipv4.ip_forward=1 ... net.ipv6.conf.all.forwarding=1 net.ipv6.conf.all.proxy_ndp = 1 ... net.ipv4.conf.all.accept_redirects = 0 net.ipv6.conf.all.accept_redirects = 0 ... net.ipv4.conf.all.send_redirects = 0 接下来,可以先做iptable,使得openvpn server对包进行SNAT iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE 或者 iptables -t nat -A POSTROUTING -s 10.11.0.0/16 -j SNAT --to 172.16.8.1 编辑/etc/openvpn/variables变量 ...

2024年1月24日

Tomcat推荐的日志记录格式

我们tomcat的日志记录格式为: pattern="%a|%A|%T|%{X-Forwarded-For}i|%l|%u|%t|%r|%s|%b|%{Referer}i|%{User-Agent}i " resolveHosts="false"/> 都是什么意思呢? %a - Remote IP address %A - Local IP address %b - Bytes sent, excluding HTTP headers, or ‘-’ if zero %B - Bytes sent, excluding HTTP headers %h - Remote host name (or IP address if resolveHosts is false) %H - Request protocol %l - Remote logical username from identd (always returns ‘-’) %m - Request method (GET, POST, etc.) %p - Local port on which this request was received %q - Query string (prepended with a ‘?’ if it exists) %r - First line of the request (method and request URI) %s - HTTP status code of the response %S - User session ID %t - Date and time, in Common Log Format %u - Remote user that was authenticated (if any), else ‘-’ %U - Requested URL path %v - Local server name %D - Time taken to process the request, in millis %T - Time taken to process the request, in seconds %I - Current request thread name (can compare later with stacktraces) 另外,还可以将request请求的查询参数、session会话变量值、cookie值或HTTP请求/响应头内容的变量值等内容写入到日志文件。 ...

2024年1月24日

Freelancer的任务之一:多IP多重匿名代理加认证

Freelancer上有个proxy setup的任务: Project Description Hi, I would like to create a new VPS proxy server with multiple IPs on the same VPS. Are you able to that? What OS do you prefer? - I have 10 ips. - I want them to be as much anonymous as you can. - I would have an Username and Password as auth, but if needed the possibility to have an IP authentication too. My budget is: ~20$ Thank you in advance. 说老实话,10个IP没必要,一个IP足够了,用Tor+polipo即可。 ...

2024年1月24日

Freelancer任务之二:建一个scramble obfuscated opevpn

这个很奇怪撒,仔细查了下,原作者是这么说的: I have created a patch which introduces some forms of scrambling to the packet payload of any OpenVPN connection. I have been successfully using the patch with Iranian and Chinese users for some time now. 看来伊朗也比较糟糕啊。 无语,鉴于在森华易腾无法建openvpn,不知道是直接封了1194的udp端口,还是从协议上封掉了openvpn,总之,都很shit。 简单说就是对openvpn协议进行了混淆,多了一个配置项: scramble 参数 scramble reverse #对传输的数据进行反转,通常这一句就已经可以绕过China和Iran的检测机制了 scramble xorptrpos #对传输的package中的有效数据进行xor运算 scramble obfuscate password #更强烈的加密。反转+xor+密码三种方式全用上. "password" 是你设定的密码 用上这个配置项后,建议设置cipher none, 因为如此这般以后,没有必要再制定cipher方式了。另外,用cipher会消耗cpu,而采用scramble消耗cpu的程度比cipher低。 搭一个试试看 这里采用的是openvpn 2.4.4版本和相应的patch 下载: 2.4.4.zip master.zip #centos yum -y install unzip yum -y groupinstall "development tools" #ubuntu apt update apt install build-essential unzip -x 2.4.4.zip unzip -x master.zip 应用补丁: ...

2024年1月24日

Freelancer任务之三:Setup Proxy on VPS for Instagram

任务的要求是: • Multiple subnets to avoid bans •I need the proxies to have the ability of User:Pass •Proxy needs to be Residential IPv6 还给出了一个参考: https://www.blackhatworld.com/seo/never-buy-proxies-again-setup-your-own-proxy-server.872539/ 恩,比较有意思。按照他给的连接: 第一步去 LowEndBox.com 或者 Webhostingtalk.com 去找一家口碑比较好,而且能提供附加ip的VPS供应商,通常附加一个IP是1$一个月。 第二步买个VPS,配置是1G内存,1个内核,100M带宽,并且附加10个IP。 这样的VPS一般是5$一个月,10$10个ip一个月,合计15$一个月,100元人民币,这样你就有11个IP可用了。 按这个任务的要求,需要Multiple subnet,你就从这家供应商的不同地点多买几台,比如洛杉矶1台,德州1台,纽约1台,然后每台附加10个IP 第三步就是安装Proxy软件了: 下载3Proxy wget http://img.rendoumi.com/soft/3proxy/0.8.11.tar.gz tar zxvf 0.8.11.tar.gz 编译安装: cd 3proxy-0.8.11 sed -i 's/^prefix.*/prefix=\/usr\/local\/3proxy/' Makefile.Linux sed -i '/DENY.*/a #define ANONYMOUS 1' src/proxy.h make -f Makefile.Linux make -f Makefile.Linux install 注意上面我是安装到了/usr/local/3proxy,大家可以根据需求修改。 看看配置都是什么 cat cfg/3proxy.cfg.sample |grep -v ^# | grep -v ^$ nserver 10.1.2.1 nserver 10.2.2.2 nscache 65536 timeouts 1 5 30 60 180 1800 15 60 users 3APA3A:CL:3apa3a "test:CR:$1$qwer$CHFTUFGqkjue9HyhcMHEe1" service log c:\3proxy\logs\3proxy.log D logformat "- +_L%t.%. %N.%p %E %U %C:%c %R:%r %O %I %h %T" archiver rar rar a -df -inul %A %F rotate 30 auth iponly external 10.1.1.1 internal 192.168.1.1 auth none dnspr auth strong deny * * 127.0.0.1,192.168.1.1 allow * * * 80-88,8080-8088 HTTP allow * * * 443,8443 HTTPS proxy -n auth none pop3p tcppm 25 mail.my.provider 25 auth strong flush allow 3APA3A,test maxconn 20 socks auth strong flush internal 127.0.0.1 allow 3APA3A 127.0.0.1 maxconn 3 admin 一堆的废物配置啊,统统去掉 ...

2024年1月24日

Freelancer任务之四squid查询用户浏览记录

这个需求也比较简单: User Browsing Log for Open VPN server 简单说就是用户连到他的openvpn服务器,通过上面的squid代理来浏览其他网站,比较特别的是需要查看用户http和https的浏览记录。 squid做透明代理,这样就可以截取浏览记录并且提供加速了 服务器是Ubuntu,缺省安装的的squid是不支持SSL的,所以需要重新编译一个 安装依赖包: sudo apt-get install build-essential fakeroot devscripts gawk gcc-multilib dpatch sudo apt-get build-dep squid3 sudo apt-get build-dep openssl sudo apt-get install libssl-dev sudo apt-get source squid3 下载到squid的源代码,以及ubuntu的修改包,解压并释放: tar zxvf squid3_3.5.12.orig.tar.gz cd squid3-3.5.12 tar xf ../squid3_3.5.12-1ubuntu7.5.debian.tar.xz 修改参数增加对ssl的支持: vi debian/rules Add --with-openssl --enable-ssl --enable-ssl-crtd under the DEB_CONFIGURE_EXTRA_FLAGS section. DEB_CONFIGURE_EXTRA_FLAGS := BUILDCXXFLAGS="$(CXXFLAGS) $(LDFLAGS)" \ ... --with-default-user=proxy \ --with-openssl \ --enable-ssl \ --enable-ssl-crtd ... 编译,会生成7个deb包 ...

2024年1月24日