diff --git a/lib/logstash/inputs/syslog.rb b/lib/logstash/inputs/syslog.rb index cfff794..9abb5da 100644 --- a/lib/logstash/inputs/syslog.rb +++ b/lib/logstash/inputs/syslog.rb @@ -138,7 +138,11 @@ def udp_listener(output_queue) @logger.info("Starting syslog udp listener", :address => "#{@host}:#{@port}") @udp.close if @udp - @udp = UDPSocket.new(Socket::AF_INET) + if IPAddr.new(@host).ipv6? + @udp = UDPSocket.new(Socket::AF_INET6) + elsif IPAddr.new(@host).ipv4? + @udp = UDPSocket.new(Socket::AF_INET) + end @udp.do_not_reverse_lookup = true @udp.bind(@host, @port)