@@ -514,6 +514,43 @@ conf_append_bind()
514
514
done
515
515
}
516
516
517
+ conf_append_bind_interface ()
518
+ {
519
+ local bind_type=" $1 "
520
+ local port=" $2 "
521
+ local interfaces=" $3 "
522
+ local ipv6_server=" $4 "
523
+ local ARGS=" $5 "
524
+ local intf=" "
525
+
526
+ . /lib/functions/network.sh
527
+
528
+ for intf in ${interfaces} ; do
529
+ local __device
530
+ local __addrs
531
+ network_get_device __device $intf
532
+ [ -z " $__device " ] && continue
533
+
534
+ if [ " $ipv6_server " = " 1" ]; then
535
+ local __addr
536
+ __addr=$( ifconfig " $__device " | grep ' Scope:Link' \
537
+ | sed ' s:.*\(fe[8ab].*\)/.*:\1:' )
538
+
539
+ conf_append " $bind_type " " [${__addr} ]:${port} @${__device} $ARGS "
540
+
541
+ network_get_ipaddrs6 __addrs " $intf "
542
+ for __addr in ${__addrs} ; do
543
+ conf_append " $bind_type " " [${__addr} ]:${port} @${__device} $ARGS "
544
+ done
545
+ fi
546
+
547
+ network_get_ipaddrs __addrs " $intf "
548
+ for __addr in ${__addrs} ; do
549
+ conf_append " $bind_type " " [${__addr} ]:${port} @${__device} $ARGS "
550
+ done
551
+ done
552
+ }
553
+
517
554
load_second_server ()
518
555
{
519
556
local section=" $1 "
@@ -739,6 +776,7 @@ load_service()
739
776
740
777
config_get_bool bind_device " $section " " bind_device" " 0"
741
778
config_get bind_device_name " $section " " bind_device_name" " ${lan_device} "
779
+ config_get bind_interfaces " $section " " bind_interface" " "
742
780
[ ! -z " $bind_device_name " ] && [ " $bind_device " = " 1" ] && device=" ${bind_device_name} "
743
781
744
782
config_get cache_file " $section " " cache_file" " $SMARTDNS_CONF_DIR /smartdns.cache"
@@ -829,10 +867,18 @@ load_service()
829
867
[ " $auto_set_dnsmasq " = " 0" ] && [ " $old_auto_set_dnsmasq " = " 1" ] && stop_forward_dnsmasq " $old_port " " 0"
830
868
}
831
869
832
- conf_append_bind " bind" " $port " " $device " " $ipv6_server " " $server_flags "
833
- [ " $tcp_server " = " 1" ] && conf_append_bind " bind-tcp" " $port " " $device " " $ipv6_server " " $server_flags "
834
- [ " $tls_server " = " 1" ] && conf_append_bind " bind-tls" " $tls_server_port " " $device " " $ipv6_server " " $server_flags "
835
- [ " $doh_server " = " 1" ] && conf_append_bind " bind-https" " $doh_server_port " " $device " " $ipv6_server " " $server_flags "
870
+ local __conf_bin_func
871
+ if [ ! -z $bind_interfaces ]; then
872
+ __conf_bin_func=" conf_append_bind_interface"
873
+ device=${bind_interfaces}
874
+ else
875
+ __conf_bin_func=" conf_append_bind"
876
+ fi
877
+
878
+ $__conf_bin_func " bind" " $port " " $device " " $ipv6_server " " $server_flags "
879
+ [ " $tcp_server " = " 1" ] && $__conf_bin_func " bind-tcp" " $port " " $device " " $ipv6_server " " $server_flags "
880
+ [ " $tls_server " = " 1" ] && $__conf_bin_func " bind-tls" " $tls_server_port " " $device " " $ipv6_server " " $server_flags "
881
+ [ " $doh_server " = " 1" ] && $__conf_bin_func " bind-https" " $doh_server_port " " $device " " $ipv6_server " " $server_flags "
836
882
837
883
[ ! -z " $bind_cert " ] && conf_append " bind-cert-file" " $bind_cert "
838
884
[ ! -z " $bind_cert_key " ] && conf_append " bind-cert-key-file" " $bind_cert_key "
0 commit comments