透過 Windows NPS 服務驗証 Cisco 設備登入機制
以往都習慣用 Linux + FreeRADIUS 去完成登入驗證(OTP)
https://xrcd2.blogspot.com/2016/01/cisco-radius-otp.html
這次換成 Windows NPS ,實驗截圖如下:
透過 Windows NPS 服務驗証 Cisco 設備登入機制
以往都習慣用 Linux + FreeRADIUS 去完成登入驗證(OTP)
https://xrcd2.blogspot.com/2016/01/cisco-radius-otp.html
這次換成 Windows NPS ,實驗截圖如下:
pfSense + FortiGate VPN 登入驗證使用 OTP
先前導讀相關 Blog
FreeRADIUS 搭配 Google Authenticator 完成 2FA [ 透過 pfSense ]
https://xrcd2.blogspot.com/2025/04/freeradius-google-authenticator-2fa.html
相關運用圖解如下 : PS: 圖左功能可由 pfSense 取代
Hub#sh run
Building configuration...
Current configuration : 1881 bytes
!
version 15.1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Hub
!
!
!
!
!
!
!
!
no ip cef
no ipv6 cef
!
!
!
!
license udi pid CISCO2811/K9 sn FTX101740QY-
!
!
!
crypto isakmp policy 10
authentication pre-share
!
crypto isakmp key cisco address 192.168.1.10
!
!
!
crypto ipsec transform-set vpnset esp-des esp-sha-hmac
!
crypto map myvpn 10 ipsec-isakmp
set peer 192.168.1.10
set transform-set vpnset
match address 100
!
!
!
!
!
!
spanning-tree mode pvst
!
!
!
!
!
!
interface Tunnel0
ip address 10.1.1.1 255.255.255.252
mtu 1476
tunnel source Ethernet1/0
tunnel destination 192.168.1.10
!
!
interface Tunnel1
ip address 10.1.1.5 255.255.255.252
mtu 1476
tunnel source Ethernet1/1
tunnel destination 192.168.1.10
!
!
interface FastEthernet0/0
ip address 172.16.1.254 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
no ip address
duplex auto
speed auto
shutdown
!
interface Ethernet1/0
ip address 192.168.1.2 255.255.255.252
duplex auto
speed auto
crypto map myvpn
!
interface Ethernet1/1
ip address 192.168.1.6 255.255.255.252
duplex auto
speed auto
crypto map myvpn
!
interface Ethernet1/2
no ip address
duplex auto
speed auto
shutdown
!
interface Ethernet1/3
no ip address
duplex auto
speed auto
shutdown
!
interface Vlan1
no ip address
shutdown
!
ip classless
ip route 192.168.1.8 255.255.255.252 Ethernet1/0
ip route 192.168.1.8 255.255.255.252 Ethernet1/1 200
ip route 172.16.2.0 255.255.255.0 10.1.1.2
ip route 172.16.2.0 255.255.255.0 10.1.1.6 200
!
ip flow-export version 9
!
!
access-list 100 permit ip host 192.168.1.10 host 192.168.1.2
access-list 100 permit ip host 192.168.1.10 host 192.168.1.6
access-list 100 permit ip 172.16.2.0 0.0.0.255 172.16.1.0 0.0.0.255
!
!
!
!
!
!
line con 0
!
line aux 0
!
line vty 0 4
login
!
!
!
end
Hub#sh ip int brie
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 172.16.1.254 YES NVRAM up up
FastEthernet0/1 unassigned YES NVRAM administratively down down
Ethernet1/0 192.168.1.2 YES NVRAM up up
Ethernet1/1 192.168.1.6 YES NVRAM up up
Ethernet1/2 unassigned YES NVRAM administratively down down
Ethernet1/3 unassigned YES NVRAM administratively down down
Tunnel0 10.1.1.1 YES NVRAM up up
Tunnel1 10.1.1.5 YES NVRAM up up
Vlan1 unassigned YES NVRAM administratively down down
Hub#sh ip route connected
C 10.1.1.0/30 is directly connected, Tunnel0
C 10.1.1.4/30 is directly connected, Tunnel1
C 172.16.1.0/24 is directly connected, FastEthernet0/0
C 192.168.1.0/30 is directly connected, Ethernet1/0
C 192.168.1.4/30 is directly connected, Ethernet1/1
Hub#sh ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
C 10.1.1.0/30 is directly connected, Tunnel0
L 10.1.1.1/32 is directly connected, Tunnel0
C 10.1.1.4/30 is directly connected, Tunnel1
L 10.1.1.5/32 is directly connected, Tunnel1
172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks
C 172.16.1.0/24 is directly connected, FastEthernet0/0
L 172.16.1.254/32 is directly connected, FastEthernet0/0
S 172.16.2.0/24 [1/0] via 10.1.1.2
192.168.1.0/24 is variably subnetted, 5 subnets, 2 masks
C 192.168.1.0/30 is directly connected, Ethernet1/0
L 192.168.1.2/32 is directly connected, Ethernet1/0
C 192.168.1.4/30 is directly connected, Ethernet1/1
L 192.168.1.6/32 is directly connected, Ethernet1/1
S 192.168.1.8/30 is directly connected, Ethernet1/0
Hub#sh crypto map
Crypto Map myvpn 10 ipsec-isakmp
Peer = 192.168.1.10
Extended IP access list 100
access-list 100 permit ip host 192.168.1.10 host 192.168.1.2
access-list 100 permit ip host 192.168.1.10 host 192.168.1.6
access-list 100 permit ip 172.16.2.0 0.0.0.255 172.16.1.0 0.0.0.255
Current peer: 192.168.1.10
Security association lifetime: 4608000 kilobytes/3600 seconds
PFS (Y/N): N
Transform sets={
vpnset,
}
Interfaces using crypto map myvpn:
Ethernet1/0
Ethernet1/1
Hub#
===============================================================
Spoke#sh run
Building configuration...
Current configuration : 2050 bytes
!
version 15.1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Spoke
!
!
!
!
!
!
!
!
no ip cef
no ipv6 cef
!
!
!
!
license udi pid CISCO2811/K9 sn FTX10175231-
!
!
!
crypto isakmp policy 10
authentication pre-share
!
crypto isakmp key cisco address 192.168.1.2
crypto isakmp key cisco address 192.168.1.6
!
!
!
crypto ipsec transform-set vpnset esp-des esp-sha-hmac
!
crypto map myvpn 10 ipsec-isakmp
set peer 192.168.1.2
set peer 192.168.1.6
set transform-set vpnset
match address 100
!
!
!
!
!
!
spanning-tree mode pvst
!
!
!
!
!
!
interface Tunnel0
ip address 10.1.1.2 255.255.255.252
mtu 1476
tunnel source Ethernet1/0
tunnel destination 192.168.1.2
!
!
interface Tunnel1
ip address 10.1.1.6 255.255.255.252
mtu 1476
tunnel source Ethernet1/0
tunnel destination 192.168.1.6
!
!
interface FastEthernet0/0
ip address 172.16.2.254 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
no ip address
duplex auto
speed auto
shutdown
!
interface Ethernet1/0
ip address 192.168.1.10 255.255.255.252
duplex auto
speed auto
crypto map myvpn
!
interface Ethernet1/1
no ip address
duplex auto
speed auto
shutdown
crypto map myvpn
!
interface Ethernet1/2
no ip address
duplex auto
speed auto
shutdown
!
interface Ethernet1/3
no ip address
duplex auto
speed auto
shutdown
!
interface Vlan1
no ip address
shutdown
!
ip classless
ip route 172.16.1.0 255.255.255.0 10.1.1.1
ip route 172.16.1.0 255.255.255.0 10.1.1.5 200
ip route 192.168.1.0 255.255.255.252 Ethernet1/0
ip route 192.168.1.4 255.255.255.252 Ethernet1/0
!
ip flow-export version 9
!
!
access-list 100 permit ip host 192.168.1.2 host 192.168.1.10
access-list 100 permit ip host 192.168.1.6 host 192.168.1.10
access-list 100 permit ip host 192.168.1.2 host 192.168.1.14
access-list 100 permit ip host 192.168.1.6 host 192.168.1.14
access-list 100 permit ip 172.16.1.0 0.0.0.255 172.16.2.0 0.0.0.255
!
!
!
!
!
!
line con 0
!
line aux 0
!
line vty 0 4
login
!
!
!
end
Spoke#sh ip int brie
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 172.16.2.254 YES NVRAM up up
FastEthernet0/1 unassigned YES NVRAM administratively down down
Ethernet1/0 192.168.1.10 YES NVRAM up up
Ethernet1/1 unassigned YES NVRAM administratively down down
Ethernet1/2 unassigned YES NVRAM administratively down down
Ethernet1/3 unassigned YES NVRAM administratively down down
Tunnel0 10.1.1.2 YES NVRAM up up
Tunnel1 10.1.1.6 YES NVRAM up up
Vlan1 unassigned YES NVRAM administratively down down
Spoke#sh ip route connected
C 10.1.1.0/30 is directly connected, Tunnel0
C 10.1.1.4/30 is directly connected, Tunnel1
C 172.16.2.0/24 is directly connected, FastEthernet0/0
C 192.168.1.8/30 is directly connected, Ethernet1/0
Spoke#sh ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
C 10.1.1.0/30 is directly connected, Tunnel0
L 10.1.1.2/32 is directly connected, Tunnel0
C 10.1.1.4/30 is directly connected, Tunnel1
L 10.1.1.6/32 is directly connected, Tunnel1
172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks
S 172.16.1.0/24 [1/0] via 10.1.1.1
C 172.16.2.0/24 is directly connected, FastEthernet0/0
L 172.16.2.254/32 is directly connected, FastEthernet0/0
192.168.1.0/24 is variably subnetted, 4 subnets, 2 masks
S 192.168.1.0/30 is directly connected, Ethernet1/0
S 192.168.1.4/30 is directly connected, Ethernet1/0
C 192.168.1.8/30 is directly connected, Ethernet1/0
L 192.168.1.10/32 is directly connected, Ethernet1/0
Spoke#sh cry map
Crypto Map myvpn 10 ipsec-isakmp
Peer = 192.168.1.2
Peer = 192.168.1.6
Extended IP access list 100
access-list 100 permit ip host 192.168.1.2 host 192.168.1.10
access-list 100 permit ip host 192.168.1.6 host 192.168.1.10
access-list 100 permit ip host 192.168.1.2 host 192.168.1.14
access-list 100 permit ip host 192.168.1.6 host 192.168.1.14
access-list 100 permit ip 172.16.1.0 0.0.0.255 172.16.2.0 0.0.0.255
Current peer: 192.168.1.2
Security association lifetime: 4608000 kilobytes/3600 seconds
PFS (Y/N): N
Transform sets={
vpnset,
}
Interfaces using crypto map myvpn:
Ethernet1/0
Ethernet1/1
Spoke#
References
https://deltaconfig.com/ip-nat-outside/
My Lab Setting
Cisco
csr1000v#sh run
Building configuration...
Current configuration : 1391 bytes
!
! Last configuration change at 08:55:23 TPE Sun Oct 2 2022 by cisco
!
version 15.5
service timestamps debug datetime localtime
service timestamps log datetime localtime
no platform punt-keepalive disable-kernel-core
platform console auto
!
hostname csr1000v
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
clock timezone TPE 8 0
!
subscriber templating
!
multilink bundle-name authenticated
!
!
!
license udi pid CSR1000V sn 9VRJUL4JW2V
license boot level ax
spanning-tree extend system-id
!
username cisco privilege 15 secret 5 $1$7wax$evNlQZGH2VorRL3bm/SRV0
!
redundancy
!
!
interface GigabitEthernet1
ip address 192.168.1.1 255.255.255.252
ip nat outside
negotiation auto
!
interface GigabitEthernet2
ip address 172.16.1.1 255.255.255.0
ip nat inside
negotiation auto
!
interface GigabitEthernet3
ip address 192.168.100.10 255.255.255.0
negotiation auto
!
!
virtual-service csr_mgmt
ip shared host-interface GigabitEthernet1
!
ip nat outside source static 10.1.1.10 10.1.2.10
ip forward-protocol nd
!
no ip http server
ip http secure-server
ip route 0.0.0.0 0.0.0.0 192.168.1.2
ip route 10.1.2.10 255.255.255.255 10.1.1.10
!
!
snmp-server community cisco RO
!
!
control-plane
!
!
line con 0
stopbits 1
line vty 0 4
login local
transport input ssh
!
ntp server 168.95.195.12
!
end
csr1000v# sh ip nat translations
Pro Inside global Inside local Outside local Outside global
--- --- --- 10.1.2.10 10.1.1.10
tcp 172.16.1.10:47186 172.16.1.10:47186 10.1.2.10:22 10.1.1.10:22
Total number of translations: 2
csr1000v#
VyOS
vyos@VyOS-L3:~$ show configuration commands
set interfaces ethernet eth0 address '192.168.1.1/30'
set interfaces ethernet eth0 hw-id '00:0c:29:14:49:e0'
set interfaces ethernet eth1 address '172.16.1.1/24'
set interfaces ethernet eth1 hw-id '00:0c:29:14:49:ea'
set interfaces ethernet eth2 address '192.168.100.10/24'
set interfaces ethernet eth2 hw-id '00:0c:29:14:49:f4'
set interfaces loopback lo
set nat destination rule 10 destination address '10.1.2.10'
set nat destination rule 10 inbound-interface 'eth1'
set nat destination rule 10 log 'enable'
set nat destination rule 10 translation address '10.1.1.10'
set protocols static route 0.0.0.0/0 next-hop 192.168.1.2
set service ssh port '22'
set system config-management commit-revisions '100'
set system conntrack modules ftp
set system conntrack modules h323
set system conntrack modules nfs
set system conntrack modules pptp
set system conntrack modules sip
set system conntrack modules sqlnet
set system conntrack modules tftp
set system console device ttyS0 speed '115200'
set system host-name 'VyOS-L3'
set system login user vyos authentication encrypted-password '$6$tBrkCg.1Y8NuExC$Ivwq8e7//904.UjhwRtz4/9edu6MTczLalZHJnk20fJbZZA2dhWkSo/H6yQ/GBdOST9eUJlpehJwj0COhq1Wp1'
set system login user vyos authentication plaintext-password ''
set system ntp server time1.vyos.net
set system ntp server time2.vyos.net
set system ntp server time3.vyos.net
set system syslog global facility all level 'info'
set system syslog global facility protocols level 'debug'
vyos@VyOS-L3:~$ show nat destination rules
Disabled rules are not shown
Codes: X - exclude rule
rule intf translation
---- ---- -----------
10 eth1 daddr 10.1.2.10 to 10.1.1.10
proto-all dport ANY
vyos@VyOS-L3:~$ show nat destination statistics
rule pkts bytes interface
---- ---- ----- ---------
10 88 5304 eth1
vyos@VyOS-L3:~$ show nat destination translations
Pre-NAT Post-NAT Prot Timeout
10.1.2.10 10.1.1.10 tcp 431978
vyos@VyOS-L3:~$ show log nat
/var/log/messages:Oct 2 01:37:51 VyOS-L3 kernel: [ 1796.299962] [NAT-DST-10] IN=eth1 OUT= MAC=00:0c:29:14:49:ea:00:0c:29:7d:d6:23:08:00 SRC=172.16.1.10 DST=10.1.2.10 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=47467 DF PROTO=ICMP TYPE=8 CODE=0 ID=4811 SEQ=1
/var/log/messages:Oct 2 01:38:23 VyOS-L3 kernel: [ 1827.865467] [NAT-DST-10] IN=eth1 OUT= MAC=00:0c:29:14:49:ea:00:0c:29:7d:d6:23:08:00 SRC=172.16.1.10 DST=10.1.2.10 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=64953 DF PROTO=TCP SPT=58076 DPT=22 WINDOW=64240 RES=0x00 SYN URGP=0
最近又有人在問我如何做 Cisco 或 FortiGate 設定組態 (configuration)
如何自動備份?
N年前我就有寫過類似的東西,只不過在當時我是用 Perl + telnet DIY小程式去做.
當然也是改成 Perl + ssh DIY 的小程式去做.但 N 年過去了,
目前已有太多工具可以逹成這個目地.
接下來的筆記是記錄,我是如何透過 Oxidized 去做這件事,
順便將其整合進 LibreNMS內,
當然只使用 Oxidized 也是 OK 的.
參考文件
http://blog.jason.tools/2021/02/librenms-oxidized.html
官方 URL
https://docs.librenms.org/Extensions/Oxidized/
https://github.com/ytti/oxidized
之前寫的東西
http://xrcd2.blogspot.com/2013/02/cisco-show-run-config-perl.html
自動備份 cisco 設備 show run 的 config ( 使用 perl )
http://xrcd2.blogspot.com/2016/01/cisco-ios-configuration-cisco-config.html
Cisco IOS 設備 configuration 自動版本管理的方式 ( cisco config auto 2 svn )
------------------------------------------------------------------------
安裝 Oxidized (OS CentOS 7.9)
yum install -y centos-release-scl-rh
yum install -y rh-ruby24 rh-ruby24-ruby-devel
yum install make cmake which sqlite-devel openssl-devel libssh2-devel ruby gcc ruby-devel libicu-devel gcc-c++
gem install oxidized oxidized-web