Openstack如何正确激活vpnaas日志?

问题描述 投票:0回答:3

我们使用 openstack ansible 构建了一个 openstack 集群,我们对此非常满意。实际上我正在尝试设置VPN。我们已经激活了所有必要的东西,并在我们的 openstack 和 sonicwall 之间进行了成功的尝试。我们现在正在与一位客户尝试,不幸的是连接没有建立,我正在寻找一些日志,但似乎没有记录任何内容。

我们使用 Openstack Ussuri 和 Ubuntu 20.04

我们已激活Strongswan

下面是一些配置文件:

控制器节点: /etc/neutron/neutron.conf

[DEFAULT]
# Disable stderr logging
use_stderr = false
debug = true
publish_errors = true
fatal_deprecations = False
use_journal = True
## Rpc all
executor_thread_pool_size = 64
rpc_response_timeout = 60
transport_url = hide
# Domain to use for building hostnames
dns_domain = openstacklocal
# Agent

[agent]
polling_interval = 5
report_interval = 60
root_helper = sudo /openstack/venvs/neutron-21.0.0/bin/neutron-rootwrap 
/etc/neutron/rootwrap.conf
root_helper_daemon = sudo /openstack/venvs/neutron-21.0.0/bin/neutron- 
rootwrap-daemon /etc/neutron/rootwrap.conf
# Messaging

[oslo_messaging_rabbit]
ssl = True
rpc_conn_pool_size = 30
# Notifications

[oslo_messaging_notifications]
topics = notifications
driver = messagingv2
transport_url = hide
# Concurrency (locking mechanisms)

[oslo_concurrency]
lock_path = /var/lock/neutron

/etc/neutron/l3_agent.ini:

[DEFAULT]
debug = True
# Drivers
interface_driver = linuxbridge
agent_mode = legacy
# Conventional failover
allow_automatic_l3agent_failover = True
# HA failover
ha_confs_path = /var/lib/neutron/ha_confs
ha_vrrp_advert_int = 2
ha_vrrp_auth_password = hide
ha_vrrp_auth_type = PASS
# Metadata
enable_metadata_proxy = True
# L3 plugins
# VPNaaS

[vpnagent]
vpn_device_driver = neutron_vpnaas.services.vpn.device_drivers.strongswan_ipsec.StrongSwanDriver

[AGENT]
extensions = vpnaas

/etc/neutron/neutron_vpnaas.conf:

[service_providers]
service_provider = VPN:strongswan:neutron_vpnaas.services.vpn.service_drivers.ipsec.IPsecVPNDriver:default

/etc/neutron/rootwrap.conf:

[DEFAULT]
# List of directories to load filter definitions from (separated by ',').
# These directories MUST all be only writeable by root !
# List of directories to search executables in, in case filters do not
# explicitely specify a full path (separated by ',')
# If not specified, defaults to system PATH environment variable.
# These directories MUST all be only writeable by root !
# Enable logging to syslog
# Default value is False
use_syslog = False
# Which syslog facility to use.
# Valid values include auth, authpriv, syslog, local0, local1...
# Default value is 'syslog'
syslog_log_facility = syslog
# Which messages to log.
# INFO means log all usage
# ERROR means only log unsuccessful attempts
syslog_log_level = ERROR
# Rootwrap daemon exits after this seconds of inactivity
daemon_timeout = 600
filters_path = /etc/neutron/rootwrap.d,/usr/share/neutron/rootwrap
exec_dirs = /openstack/venvs/neutron- 21.0.0/bin,/sbin,/usr/sbin,/bin,/usr/bin,/usr/local/bin,/usr/local/sbin

[xenapi]
# XenAPI configuration is only required by the L2 agent if it is to
# target a XenServer/XCP compute host's dom0.
xenapi_connection_url = <None>
xenapi_connection_username = root
xenapi_connection_password = <None>

/openstack/venvs/neutron-21.0.0/lib/python3.8/site-packages/neutron_vpnaas/services/vpn/device_drivers/template/strongswan/ipsec.conf.template:

# Configuration for {{vpnservice.id}}
config setup
  charondebug="ike 4, knl 4,net 4,enc 4,chd 4,esp 4,cfg 2,dmn 4,mgr 4,asn 4"
conn %default
        keylife=20m
        rekeymargin=3m
        keyingtries=1
        authby=psk
        mobike=no
{% for ipsec_site_connection in vpnservice.ipsec_site_connections%}
conn {{ipsec_site_connection.id}}
    keyexchange={{ipsec_site_connection.ikepolicy.ike_version}}
    left={{ipsec_site_connection.external_ip}}
    leftsubnet={{ipsec_site_connection['local_cidrs']|join(',')}}
    leftid={{ipsec_site_connection.local_id}}
    leftfirewall=yes
    right={{ipsec_site_connection.peer_address}}
    rightsubnet={{ipsec_site_connection['peer_cidrs']|join(',')}}
    rightid={{ipsec_site_connection.peer_id}}
    auto=route
    dpdaction={{ipsec_site_connection.dpd_action}}
    dpddelay={{ipsec_site_connection.dpd_interval}}s
    dpdtimeout={{ipsec_site_connection.dpd_timeout}}s
    ike={{ipsec_site_connection.ikepolicy.encryption_algorithm}}-{{ipsec_site_connection.ikepolicy.auth_algorithm}}-{{ipsec_site_connection.ikepolicy.pfs}}
    ikelifetime={{ipsec_site_connection.ikepolicy.lifetime_value}}s
    {%- if ipsec_site_connection.ipsecpolicy.transform_protocol == "ah" %}
    ah={{ipsec_site_connection.ipsecpolicy.auth_algorithm}}-{{ipsec_site_connection.ipsecpolicy.pfs}}
    {%- else %}
    esp={{ipsec_site_connection.ipsecpolicy.encryption_algorithm}}-{{ipsec_site_connection.ipsecpolicy.auth_algorithm}}-{{ipsec_site_connection.ipsecpolicy.pfs}}
    {%- endif %}
    lifetime={{ipsec_site_connection.ipsecpolicy.lifetime_value}}s
    type={{ipsec_site_connection.ipsecpolicy.encapsulation_mode}}
{% endfor %}

如果有人可以帮助我激活日志那就太好了

谢谢

vpn openstack strongswan
3个回答
1
投票

除了第一篇文章之外,我终于成功激活了日志,位于我的配置下方: 在控制器上:

/etc/strongswan.d/charon-logging.conf

卡戎{

# Section to define file loggers, see LOGGER CONFIGURATION in                                                                                                                                                                                                              
# strongswan.conf(5).                                                                                                                                                                                                                                                      
filelog {                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                           
    # <name> may be the full path to the log file if it only contains                                                                                                                                                                                                      
    # characters permitted in section names. Is ignored if path is                                                                                                                                                                                                         
    # specified.                                                                                                                                                                                                                                                           
      charon {                                                                                                                                                                                                                                                             
                                                                                                                                                                                                                                                                           
        # Loglevel for a specific subsystem.                                                                                                                                                                                                                               
        # <subsystem> = <default>                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                           
        # If this option is enabled log entries are appended to the existing                                                                                                                                                                                               
        # file.                                                                                                                                                                                                                                                            
          append = no                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                           
        # Default loglevel.                                                                                                                                                                                                                                                
          default = 3                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                           
        # Enabling this option disables block buffering and enables line                                                                                                                                                                                                   
        # buffering.                                                                                                                                                                                                                                                       
          flush_line = yes                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                           
        # Prefix each log entry with the connection name and a unique                                                                                                                                                                                                      
        # numerical identifier for each IKE_SA.
          ike_name = yes

        # Optional path to the log file. Overrides the section name. Must be
        # used if the path contains characters that aren't allowed in
        # section names.
          path = /var/log/charon-ike.log

        # Adds the milliseconds within the current second after the
        # timestamp (separated by a dot, so time_format should end with %S
        # or %T).
          time_add_ms = yes

        # Prefix each log entry with a timestamp. The option accepts a
        # format string as passed to strftime(3).
          time_format = %b %e %T

      }

}

# Section to define syslog loggers, see LOGGER CONFIGURATION in
# strongswan.conf(5).
syslog {

    # Identifier for use with openlog(3).
 #     identifier = CHARON

    # <facility> is one of the supported syslog facilities, see LOGGER
    # CONFIGURATION in strongswan.conf(5).
    #  auth {

        # Loglevel for a specific subsystem.
        # <subsystem> = <default>

        # Default loglevel.
     #    default = 2

        # Prefix each log entry with the connection name and a unique
        # numerical identifier for each IKE_SA.
      #    ike_name = yes

     # }

   }

}

最重要的是:

sudo apparmor_parser -R /etc/apparmor.d/usr.lib.ipsec.charon

使用此配置,您将在 /var/log/charon-ike.log 下有一个日志文件。 也许你需要重新启动 neutron

感谢您的帮助;)


0
投票

这不是答案,但它使它更具可读性。我们没有触及 Charon 配置,但这就是

/etc/strongswan.d/charon-logging.conf
:

charon {

    # Section to define file loggers, see LOGGER CONFIGURATION in
    # strongswan.conf(5).
    filelog {

        # <filename> is the full path to the log file.
        # <filename> {

            # Loglevel for a specific subsystem.
            # <subsystem> = <default>

            # If this option is enabled log entries are appended to the existing
            # file.
            # append = yes

            # Default loglevel.
            # default = 1

            # Enabling this option disables block buffering and enables line
            # buffering.
            # flush_line = no

            # Prefix each log entry with the connection name and a unique
            # numerical identifier for each IKE_SA.
            # ike_name = no

            # Prefix each log entry with a timestamp. The option accepts a
            # format string as passed to strftime(3).
            # time_format =

        # }

    }

    # Section to define syslog loggers, see LOGGER CONFIGURATION in
    # strongswan.conf(5).
    syslog {

        # Identifier for use with openlog(3).
        # identifier =

        # <facility> is one of the supported syslog facilities, see LOGGER
        # CONFIGURATION in strongswan.conf(5).
        # <facility> {

            # Loglevel for a specific subsystem.
            # <subsystem> = <default>

            # Default loglevel.
            # default = 1

            # Prefix each log entry with the connection name and a unique
            # numerical identifier for each IKE_SA.
            # ike_name = no
        # }
    }
}

0
投票

要在 OpenStack 路由器上启用特定 VPN 服务的 VPN 日志记录,可以通过以下方式实现:

识别运行 VPN 路由器的控制节点

ROUTER_ID=$(openstack vpn service show ${VPN_SERVICE_ID} -c Router -f value)
echo "ROUTER_ID=${ROUTER_ID}"

ROUTER_PORT_ID=$(openstack port list --device-owner network:router_gateway -f value -c id --router ${ROUTER_ID})
CONTROL_NODE=$(openstack port show ${ROUTER_PORT_ID} -c binding_host_id -f value)
echo ${CONTROL_NODE}

连接到控制节点

ssh ${CONTROL_NODE}

如果您将路由器作为 Docker exec 运行到 Docker 容器中

docker exec -u root -ti neutron_l3_agent bash

定义 ROUTER_ID(来自上一个命令)

ROUTER_ID=b7ed736e-8f38-4be6-8ce4-644c5c7bfedf

在strongswan配置中启用文件日志记录

cp /var/lib/neutron/ipsec/${ROUTER_ID}/etc/strongswan.d/charon-logging.conf{,.org}
 
sed -i "s|# <name> {|charon {|g" /var/lib/neutron/ipsec/${ROUTER_ID}/etc/strongswan.d/charon-logging.conf
sed -i "s|# path =|path = /var/log/charon-${ROUTER_ID}.log|g" /var/lib/neutron/ipsec/${ROUTER_ID}/etc/strongswan.d/charon-logging.conf
sed -i "s|# append = yes|append = no|g" /var/lib/neutron/ipsec/${ROUTER_ID}/etc/strongswan.d/charon-logging.conf
## loglevel 1 should be enough. Use 2 for more details or read: https://docs.strongswan.org/docs/5.9/config/logging.html
sed -i "s|# default = 1|default = 1|g" /var/lib/neutron/ipsec/${ROUTER_ID}/etc/strongswan.d/charon-logging.conf
sed -i "s|# ike_name = no|ike_name = yes|g" /var/lib/neutron/ipsec/${ROUTER_ID}/etc/strongswan.d/charon-logging.conf
sed -i "s|# time_add_ms = no|time_add_ms = yes|g" /var/lib/neutron/ipsec/${ROUTER_ID}/etc/strongswan.d/charon-logging.conf
sed -i "s|# time_format =|time_format = %b %e %T|g" /var/lib/neutron/ipsec/${ROUTER_ID}/etc/strongswan.d/charon-logging.conf
sed -i '0,/# }/s/# }/}/' /var/lib/neutron/ipsec/${ROUTER_ID}/etc/strongswan.d/charon-logging.conf

diff /var/lib/neutron/ipsec/${ROUTER_ID}/etc/strongswan.d/charon-logging.conf{,.org}

重新启动strongswan连接

ip netns exec qrouter-${ROUTER_ID} neutron-vpn-netns-wrapper --mount_paths="/etc:/var/lib/neutron/ipsec/${ROUTER_ID}/etc,/var/run:/var/lib/neutron/ipsec/${ROUTER_ID}/var/run" --cmd="ipsec,restart"

观看 stronswan VPN 日志

tail -f /var/log/charon-${ROUTER_ID}.log

完成后,出于存储和安全原因,不要忘记再次停用 VPNaaS 日志记录。

© www.soinside.com 2019 - 2024. All rights reserved.