freerdius 踢用户下线

http://www.lc365.net/blog/b/31701/


先在ros的终端中输入引用:
/radius incoming set accept=yes这样将开启routeros的断线请求消息,并监听在端口udp 1700。
然后使用radclient构造一个踢人的数据包。
格式如下:引用:
echo "Acct-Session-Id=8100000c" > packet.txt
echo "User-Name=gtr" >> packet.txt
echo "Framed-IP-Address = 10.12.255.248" >> packet.txt

cat packet.txt | radclient -x 192.168.50.180:1701 disconnect 123解释如下:
Acct-Session-Id=8100000c ,8100000c 是freeradius使用的数据库中radacct表的AcctSessionld字段的值,表示这个拨号用户的会话ID。
User-Name=gtr                ,gtr是拨号用户的用户名。
Framed-IP-Address = 10.12.255.248 ,10.12.255.248是此拨号用户获取的IP地址。

radclient -x 192.168.50.180:1701 disconnect 123中,192.168.50.180:1701是routeros的IP地址和监听的端口,disconnect 表示发送断线消息,123是与radius与routeros 的通信密钥。

当执行此命令后,输出:引用:
[root@debian ~]# echo "Acct-Session-Id=8100000c" > packet.txt
[root@debian ~]# echo "User-Name=gtr" >> packet.txt
[root@debian ~]# echo "Framed-IP-Address = 10.12.255.248" >> packet.txt
[root@debian ~]# cat packet.txt | radclient -x 192.168.50.180:1701 disconnect 123
Sending Disconnect-Request of id 83 to 192.168.50.180 port 1701
        Acct-Session-Id = "8100000c"
        User-Name = "gtr"
        Framed-IP-Address = 10.12.255.248
rad_recv: Disconnect-ACK packet from host 192.168.50.180:1701, id=83, length=36
        NAS-Identifier = "MikroTik"
        NAS-IP-Address = 192.168.50.180
[root@debian ~]#马上就可以看到拨号用户被踢下线

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Spring Security中实现限制异地登录并用户下线,你可以按照以下步骤进行操作: 1. 创建一个自定义的AuthenticationProvider实现类,用于处理认证逻辑。你可以继承`DaoAuthenticationProvider`类,并重写`additionalAuthenticationChecks`方法。 在这个方法中,你可以获取用户的登录信息,并将其与数据库中存储的用户信息进行比较。如果发现用户已经在其他地方登录,则可以抛出一个自定义的异常,表示异地登录。 2. 创建一个自定义的`AuthenticationSuccessHandler`实现类,用于处理用户成功登录后的逻辑。在这个类中,你可以检查当前登录用户是否已经在其他地方登录。如果是,则可以采取相应的措施来掉之前的登录用户。 3. 在Spring Security的配置类中,配置上述的自定义AuthenticationProvider和AuthenticationSuccessHandler。 你可以通过重写`configure`方法来进行配置,例如: ```java @Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired private CustomAuthenticationProvider customAuthenticationProvider; @Autowired private CustomAuthenticationSuccessHandler customAuthenticationSuccessHandler; @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.authenticationProvider(customAuthenticationProvider); } @Override protected void configure(HttpSecurity http) throws Exception { http .formLogin() .successHandler(customAuthenticationSuccessHandler) .and() .logout() .logoutSuccessUrl("/login") .and() .authorizeRequests() .antMatchers("/admin/**").hasRole("ADMIN") .anyRequest().authenticated(); } } ``` 4. 在自定义的AuthenticationProvider中,你可以使用Spring Security提供的`SessionRegistry`类来获取当前所有活动的用户会话。通过遍历会话列表,你可以找到与当前用户相同的用户,并将其强制下线。 需要注意的是,上述的实现方式是基于Spring Security的Session管理机制。如果你使用了其他的会话管理方式,可能需要相应地修改实现逻辑。此外,为了确保异地登录的准确性,你可能还需要考虑一些边界情况,例如用户主动注销登录和会话过期等。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值