Cisco 路由器的操作审计

我们用的是Cisco ASR 1001-X这个路由器来做BGP的。 前两天做多线BGP的时候,也不知道是遇到Bug了,还是操作顺序有问题,大断网,然后重启路由器。 事后想回顾的时候也是各自有各自的记录,细节语焉不详…… 干脆搭建一个日志服务器来记录下来所有的操作,便于事后复盘 首先在CentOS 7 的系统上安装TACACS+软件,居然在7上用的是6的软件,这点也很怪异 cat << EOF >/etc/yum.repos.d/tacacs-plus.repo [tacacs-plus] name=Tacacs Plus baseurl=http://li.nux.ro/download/nux/misc/el6/x86_64/ enabled=0 gpgcheck=1 gpgkey=http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro EOF 安装tacacs_plus yum –enablerepo=tacacs-plus install tac_plus 注意,我们只是用tacacs_plus来记录操作日志,不是用来限制用户登录和权限的,所以只需要关注两行: vi /etc/tac_plus.conf key = "FuckFuckFuck" accounting file = /var/log/tac_acct.log ...... 启动,centos 6 没有systemctl,只有service service tac_plus start ok, tacacs+配置好了,继续,去Cisco路由器上配 Router1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router1(config)#tacacs-server host 192.168.171.13 Router1(config)#tacacs-server timeout 10 Router1(config)#tacacs-server key FuckFuckFuck Router1(config)#aaa new-model Router1(config)#aaa accounting commands 0 default stop-only group tacacs+ Router1(config)#aaa accounting commands 1 default stop-only group tacacs+ Router1(config)#aaa accounting commands 15 default stop-only group tacacs+ Router1(config)#end Router1# “0” 用来审计exit和end命令,这样可以明确知道用户的登录。 ...

2024年01月24日 · 1 分钟 · 112 字 · 八戒

KVM的虚机如何限速

需要开一台kvm的测试机,但是需要限制速度,10M 我们的物理机使用了bridge,以及vlan tag,所以虚机的网卡是br0.141 查了一圈文档 <interface type='bridge'> <mac address='52:54:00:db:4c:5f'/> <source bridge='br0.141'/> <bandwidth> <inbound average='1250' peak='1250' burst='1250'/> <outbound average='1250' peak='1250' burst='1250'/> </bandwidth> <model type='virtio'/> 注意限速的单位:是kilobyte per second 那么: 1250 kilobyte per second, KB/s = 10 Mbps = 1.25 MB/s 10 Mbps就是通常意义上的网速,/8=1.25 MB/s,就是机器上用下载软件比如迅雷下载,看到的速度(1.25 MB/s)。

2024年01月24日 · 1 分钟 · 41 字 · 八戒

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年01月24日 · 1 分钟 · 196 字 · 八戒

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年01月24日 · 1 分钟 · 49 字 · 八戒

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年01月24日 · 1 分钟 · 74 字 · 八戒

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年01月24日 · 1 分钟 · 42 字 · 八戒

配置一个提供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年01月24日 · 2 分钟 · 297 字 · 八戒

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年01月24日 · 1 分钟 · 203 字 · 八戒

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年01月24日 · 2 分钟 · 218 字 · 八戒

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年01月24日 · 3 分钟 · 587 字 · 八戒