接口地址作为服务源 IP
接口地址作为服务源 IP
DNS 数据库、RADIUS 和 LDAP 配置可以通过 source-ip-interface 引用接口名称,并使用该接口当前的 IP 地址作为服务请求的源 IP。当接口地址动态变化,或请求需要受 SD-WAN 和指定出口接口控制时,该方式可以避免在服务对象中固定源 IP 地址。
配置要点
source-ip-interface决定请求使用哪个接口的当前 IP 地址作为源 IP,配置source-ip-interface后,无法配置source-ip。interface-select-method仍然决定请求的出口选择方式,可以使用auto、sdwan或specify。- 源地址接口可以是物理接口、Loopback 接口或 VDOM Link 等,但必须确保服务器存在到该源地址的回程路径。
DNS 数据库配置
本例为 fortinet.com.cn 配置 DNS 转发器 192.168.100.99,并使用 DHCP 获取 IP 的接口 port2 的地址 作为转发查询的源 IP。
port2 通过 DHCP 方式获取 IP 配置,port2 获取的 IP 为
172.22.6.23。config system interface edit "port2" set vdom "root" set mode dhcp next end # diagnose ip address list | grep port2 IP=172.22.6.23->172.22.6.23/255.255.255.0 index=2 devname=port2配置 DNS 数据库、转发器、源地址接口、出接口。
config system dns-database edit "fortinet.com.cn" set domain "fortinet.com.cn" set authoritative disable set forwarder "192.168.100.99" set source-ip-interface "port2" set interface-select-method specify set interface port3 next end查询该区域中的测试 FQDN,触发 FortiGate 向转发器发送 DNS 请求。
# execute ping support.fortinet.com.cn PING support.fortinet.com.cn (39.105.115.226): 56 data bytes 64 bytes from 39.105.115.226: icmp_seq=0 ttl=51 time=9.0 ms ^C --- support.fortinet.com.cn ping statistics --- 1 packets transmitted, 1 packets received, 0% packet loss round-trip min/avg/max = 9.0/9.0/9.0 ms提示
为避免命中现有缓存,优先使用尚未查询过的测试 FQDN。
diagnose test application dnsproxy 1会清空 DNS 缓存,并影响设备上其他缓存查询,只应在确认影响后执行。抓取 FortiGate 与转发器之间的 DNS 流量,确认请求源地址为
172.22.6.23,出接口为port3。# diagnose sniffer packet any 'host 192.168.100.99 and port 53' 4 91.180362 port3 out 172.22.6.23.1328 -> 192.168.100.99.53: udp 41 91.180733 port3 in 192.168.100.99.53 -> 172.22.6.23.1328: udp 57当 port2 通过 DHCP 获取的 IP 地址变化为
172.22.6.28:# diagnose ip address list | grep port2 IP=172.22.6.28->172.22.6.28/255.255.255.0 index=2 devname=port2FortiGate 发出的 DNS 请求源 IP 也跟随变化:
# diagnose sniffer packet any 'host 192.168.100.99 and port 53' 4 91.180362 port3 out 172.22.6.28.1354 -> 192.168.100.99.53: udp 41 91.180733 port3 in 192.168.100.99.53 -> 172.22.6.28.1354: udp 57
RADIUS 配置
本例使用 Loopback 接口 loopback1 的地址 10.10.1.1 作为 RADIUS 请求源 IP,并通过指定接口 port2 选路。
创建 Loopback 接口。
config system interface edit "loopback1" set vdom "root" set ip 10.10.1.1 255.255.255.255 set allowaccess ping set type loopback next end配置 RADIUS 服务器对象。
config user radius edit "radius-server" set server "192.168.90.118" set secret <radius_secret> set source-ip-interface "loopback1" set interface-select-method specify set interface "port2" next end使用已知测试账号执行本地认证,并在另一个 SSH 会话中抓取 RADIUS 报文。
diagnose test authserver radius radius-server pap <username> <password>抓包中的请求源地址应为
10.10.1.1,出口为port2,符合配置预期。# diagnose sniffer packet any 'host 192.168.90.118 and port 1812' 4 port2 out 10.10.1.1.17437 -> 192.168.90.118.1812: udp 110 port2 in 10.10.1.1.17437 -> 192.168.90.118.1812: udp 110
LDAP 配置
本例使用 VDOM Link testvlink 的地址 192.168.1.1 作为 LDAP 请求源 IP,并使用 SD-WAN 选择出口。
配置 VDOM Link。
config system interface edit "testvlink1" set vdom "vdom1" set ip 192.168.1.1 255.255.255.0 set allowaccess ping set type vdom-link next end配置 LDAP 服务器对象。
config user ldap edit "ldap" set server "192.168.90.118" set source-ip-interface "testvlink1" set cnid "cn" set dn "dc=fortinet,dc=com" set type regular set username "cn=admin,dc=fortinet,dc=com" set password <ldap_password> set interface-select-method sdwan next end发起 LDAP 连接并抓取 TCP 389 报文,确认 VDOM Link 上的请求源地址为
192.168.1.1,出接口为SD-WAN选择的出接口testvlink1。# diagnose sniffer packet any 'port 389' 4 interfaces=[any] filters=[port 389] 11.356977 testvlink1 out 192.168.1.1.11742 -> 192.168.90.118.389: syn 1099805903 11.356979 testvlink0 in 192.168.1.1.11742 -> 192.168.90.118.389: syn 1099805903 11.357001 port1 out 172.22.6.64.11742 -> 192.168.90.118.389: syn 1099805903 11.357548 port1 in 192.168.90.118.389 -> 172.22.6.64.11742: syn 2083328609 ack 1099805904 11.357556 testvlink0 out 192.168.90.118.389 -> 192.168.1.1.11742: syn 2083328609 ack 1099805904 11.357558 testvlink1 in 192.168.90.118.389 -> 192.168.1.1.11742: syn 2083328609 ack 1099805904 11.357566 testvlink1 out 192.168.1.1.11742 -> 192.168.90.118.389: ack 2083328610 11.357564 testvlink0 in 192.168.1.1.11742 -> 192.168.90.118.389: ack 2083328610 11.357571 port1 out 172.22.6.64.11742 -> 192.168.90.118.389: ack 2083328610相关信息
流量跨越 VDOM Link 后,在
port1上使用了另一个源地址。testvlink1上的输出可以确认source-ip-interface已应用,但服务器端最终看到的地址还取决于后续 VDOM 和 SNAT 处理。