在登陸的時候 , 對安全性比較高的業務 , 須要進行限制指定IP或IP段才能登陸 , 企郵企業有的就限制只能在本企業內登陸 數據庫
這個時候設計一下數據庫 , 實現這個功能能夠這樣安全
表結構:spa
CREATE TABLE `iplimit_list` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `ent_id` int(10) unsigned NOT NULL DEFAULT '0', `start` int(10) unsigned NOT NULL DEFAULT '0', `end` int(10) unsigned NOT NULL DEFAULT '0', `time` int(10) unsigned NOT NULL DEFAULT '0', `type` tinyint(3) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `idx_user` (`ent_id`,`start`,`end`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8
start是ip段的開始設計
end是ip段的結束 code
都是int數值型的 , 把ip進行轉換成long類型blog
查詢的時候能夠這樣查ip
select * from iplimit_list where ent_id=23684 and 182322741>=start and 182322741<=endit
182322741這個就是當前ip , 大於等於start的ip段 , 小於等於end的ip段class
實現的效果登錄