3

Cisco 路由器的操作审计

 7 months ago
source link: https://bajie.dev/posts/20240124-cisco_audit/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Cisco 路由器的操作审计

2024-01-24 2 分钟阅读

我们用的是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命令,这样可以明确知道用户的登录。

  • “1” 用来审计非特权用户的show命令。

  • “15” 用来审计特权命令对路由器配置的改动。

看看日志里有没有记录:

image-20240124162937190

注意,tacacs-server的语法可能在ios版本不同的情况下语法不同:

# tacacs server TS-AAA
     address ipv4 192.168.171.13
     key FuckFuckFuck
     timeout 10

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK