|
| |||
|
|
(solved) IPTABLES (AIF) в Dom0 и проброс портов Приветствую, уважаемые сообщники! Синопсис: Есть хост с XEN 4.1. Всё работает прекрасно На хосте был одни сетевой интерфейс с локальным(и) адресами, на виртуалках адреса, разумеется, тоже локальные. Воткнули второй сетевой интерфейс и подключили его напрямую к рутеру провайдера. На рутере простой мост, т.е. реальный адрес - на втором интерфейсе хоста. Этот интерфейс пингуется снаружи и изнутри. Требуется пробросить порты с этого интерфейса на порты одной из виртуалок. Интерфейс не участвует во всей свистопляске Xen-а, ---------------------------------------- cat /etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback iface eth0 inet manual auto eth1 iface eth1 inet static address 123.456.789.123 netmask 255.255.255.248 gateway 123.456.789.49 auto xenbr0 iface xenbr0 inet static address 192.168.213.3 gateway 192.168.213.1 netmask 255.255.255.0 broadcast 192.168.213.255 bridge_ports eth0 ---------------------------------------- Для проброса портов решил использовать Arno Iptables Firewall - там всё достаточно просто и на _обычной_ машине (с чуть более старым ядром и версией AIF работает всё уже который год без проблем) Конфиг AIF: EXT_IF="eth1" EXT_IF_DHCP_IP=0 OPEN_TCP="22 25 80 143 993 8080 2222 2233" OPEN_UDP="" INT_IF="eth0 xenbr0" NAT=1 INTERNAL_NET="192.168.213.0/24" NAT_INTERNAL_NET="" OPEN_ICMP=1 Попробовал 2 варианта - и в самом скрипте определил: NAT_FORWARD_TCP="2233>192.168.213.222~22 25,143,993>192.168.213.213 2222>192.168.213.213~22" arno-iptables-firewall restart Arno's Iptables Firewall Script v2.0.1c ---------------------------------------- Platform: Linux 3.2.0-4-amd64 x86_64 Stopping (user) plugins... SSH Brute-Force Protection plugin v1.1a Checking/probing Iptables modules: Loaded kernel module ip_tables. Loaded kernel module nf_conntrack. Loaded kernel module nf_conntrack_ftp. Loaded kernel module xt_conntrack. Loaded kernel module xt_limit. Loaded kernel module xt_state. Loaded kernel module xt_multiport. Loaded kernel module iptable_filter. Loaded kernel module iptable_mangle. Loaded kernel module ipt_REJECT. Loaded kernel module ipt_LOG. Loaded kernel module xt_TCPMSS. Loaded kernel module iptable_nat. Loaded kernel module nf_nat. Loaded kernel module nf_nat_ftp. Loaded kernel module ipt_MASQUERADE. Module check done... Configuring general kernel parameters: Setting the max. amount of simultaneous connections to 16384 net.nf_conntrack_max = 16384 net.netfilter.nf_conntrack_udp_timeout = 60 net.netfilter.nf_conntrack_acct = 1 Configuring kernel parameters: Disabling send redirects net.ipv4.conf.all.send_redirects = 0 net.ipv4.conf.default.send_redirects = 0 net.ipv4.conf.lo.send_redirects = 0 net.ipv4.conf.eth0.send_redirects = 0 net.ipv4.conf.eth1.send_redirects = 0 net.ipv4.conf.xenbr0.send_redirects = 0 Enabling protection against source routed packets net.ipv4.conf.all.accept_source_route = 0 net.ipv4.conf.default.accept_source_rout net.ipv4.conf.lo.accept_source_route = 0 net.ipv4.conf.eth0.accept_source_route = 0 net.ipv4.conf.eth1.accept_source_route = 0 net.ipv4.conf.xenbr0.accept_source_route = 0 net.ipv4.icmp_echo_ignore_broadcasts = 1 net.ipv4.icmp_ignore_bogus_error_respons Enabling packet forwarding net.ipv4.conf.all.forwarding = 1 net.ipv4.conf.default.forwarding = 1 net.ipv4.conf.lo.forwarding = 1 net.ipv4.conf.eth0.forwarding = 1 net.ipv4.conf.eth1.forwarding = 1 net.ipv4.conf.xenbr0.forwarding = 1 Setting some kernel performance options net.ipv4.tcp_window_scaling = 1 net.ipv4.tcp_timestamps = 1 net.ipv4.tcp_sack = 1 net.ipv4.tcp_dsack = 1 net.ipv4.tcp_fack = 1 net.ipv4.tcp_low_latency = 0 Enabling reduction of the DoS'ing ability net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_keepalive_time = 1800 net.ipv4.tcp_syn_retries = 3 net.ipv4.tcp_synack_retries = 2 net.ipv4.tcp_rfc1337 = 1 net.ipv4.ip_local_port_range = 32768 61000 Enabling SYN-flood protection via SYN-cookies net.ipv4.tcp_syncookies = 1 Enabling anti-spoof with rp_filter net.ipv4.conf.all.rp_filter = 1 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.lo.rp_filter = 1 net.ipv4.conf.eth0.rp_filter = 1 net.ipv4.conf.eth1.rp_filter = 1 net.ipv4.conf.xenbr0.rp_filter = 1 net.ipv4.icmp_echo_ignore_all = 0 Disabling the logging of martians net.ipv4.conf.all.log_martians = 0 net.ipv4.conf.default.log_martians = 0 net.ipv4.conf.lo.log_martians = 0 net.ipv4.conf.eth0.log_martians = 0 net.ipv4.conf.eth1.log_martians = 0 net.ipv4.conf.xenbr0.log_martians = 0 Disabling the acception of ICMP-redirect messages net.ipv4.conf.all.accept_redirects = 0 net.ipv4.conf.default.accept_redirects = 0 net.ipv4.conf.lo.accept_redirects = 0 net.ipv4.conf.eth0.accept_redirects = 0 net.ipv4.conf.eth1.accept_redirects = 0 net.ipv4.conf.xenbr0.accept_redirects = 0 Disabling ECN (Explicit Congestion Notification) net.ipv4.tcp_ecn = 0 Disabling kernel support for dynamic IPs net.ipv4.ip_dynaddr = 0 Enabling PMTU discovery net.ipv4.ip_no_pmtu_disc = 0 Setting default TTL=64 net.ipv4.ip_default_ttl = 64 Flushing route table net.ipv4.route.flush = 1 Kernel setup done... Reinitializing firewall chains Setting all default policies to DROP while "setting up firewall rules" IPv4 mode selected but IPv6 available, DROP all IPv6 packets Using loglevel "info" for syslogd Setting up firewall rules: ---------------------------------------- Enabling setting the maximum packet size via MSS Logging of stealth scans (nmap probes etc.) enabled Logging of packets with bad TCP-flags enabled Logging of INVALID TCP packets disabled Logging of INVALID UDP packets disabled Logging of INVALID ICMP packets disabled Logging of fragmented packets enabled Logging of access from reserved nets disabled Setting up antispoof for INTERNAL net(s): 192.168.223.0/24 Reading custom rules from /etc/arno-iptables-firewall/custom-rules Checking for (user) plugins in /usr/share/arno-iptables-firewall/plugin SSH Brute-Force Protection plugin v1.1a Loaded kernel module xt_recent. Allowing bypass of SSH protection checks for: мой_домашний_адрес Protecting TCP port(s): 22 Loaded 1 plugin(s)... Setting up external(INET) INPUT policy Logging of ICMP flooding enabled Logging of explicitly blocked hosts enabled Logging of denied local output connections enabled Packets will NOT be checked for reserved source addresses Allowing ANYHOST for TCP port(s): 22 Allowing ANYHOST for TCP port(s): 25 Allowing ANYHOST for TCP port(s): 80 Allowing ANYHOST for TCP port(s): 143 Allowing ANYHOST for TCP port(s): 993 Allowing ANYHOST for TCP port(s): 8080 Allowing ANYHOST for TCP port(s): 2222 Allowing ANYHOST for TCP port(s): 2233 Allowing ANYHOST to send IPv4 ICMP-requests (ping) Logging of possible stealth scans enabled Logging of (other) packets to PRIVILEGED TCP ports enabled Logging of (other) packets to PRIVILEGED UDP ports enabled Logging of (other) packets to UNPRIVILEGED TCP ports enabled Logging of (other) packets to UNPRIVILEGED UDP ports enabled Logging of IGMP packets enabled Logging of dropped ICMP-request(ping) packets enabled Logging of dropped other ICMP packets enabled Logging of other IP protocols (non TCP/UDP/ICMP/IGMP) packets enabled Setting up external(INET) OUTPUT policy Applying external(INET) policy to interface: eth1 (without an external subnet specified) Setting up internal(LAN) INPUT policy Allowing ICMP-requests(ping) Allowing all (other) ports/protocols Applying internal(LAN) policy to interface: eth0 Applying internal(LAN) policy to interface: xenbr0 Setting up internal(LAN) FORWARD policy Logging of denied LAN->INET FORWARD connections enabled Setting up LAN->INET policy Allowing ICMP-requests(ping) Allowing all (other) ports/protocols Applying internal(LAN) FORWARD policy to interface: eth0 Applying internal(LAN) FORWARD policy to interface: xenbr0 Enabling masquerading(NAT) via external interface(s): eth1 Adding (internal) host(s): 192.168.223.0/24 (eth1) Forwarding(NAT) TCP port(s) 0/0:2233 to 192.168.213.222:22 (eth1) Forwarding(NAT) TCP port(s) 0/0:25,143,993 to 192.168.213.213 (eth1) Forwarding(NAT) TCP port(s) 0/0:2222 to 192.168.213.213:22 Security is ENFORCED for external interface(s) in the FORWARD chain Logging of dropped FORWARD packets enabled Sep 14 20:10:44 All firewall rules applied. и... не работает. И в custom-rules - они запускаются до применения всех правил AIF: #SSH port mapping iptables -t nat -A PREROUTING -p tcp -d 123.456.789.123 --dport 2233 -j DNAT --to 192.168.213.222:22 iptables -A FORWARD -p tcp -d 192.168.213.222 --dport 22 -j ACCEPT и тоже индейская хижина, хотя именно в таком виде оно трудится и работает на обычном рутере, при этом проброс происходит вообще на другие физические машины в локалке. В логах dmesg, куда обычно всё выводится, вообще ничего нет - только пакеты с левых адресов по левым портам, мои попытки подключиться к внешнему 2233 порту в надежде достучаться на 22 порт виртуалки вешаются и со временем отваливаются по тайм-ауту. Я где-то читал упоминание, что Xen для Dom0 что-то делает с внутреннеё сетевой кухней ядра, но что именно - хз. Есть возможность как-нибудь победить это всё дело и пробросить порты или придётся обойтись только проброской PCI устройства в виртуалку и ограничится только одной виртуалкой? (никогда проброску устройств не делал, но читал, что работает). Заранее всем КУ! UPDATE: Несмотря на то, что в конфиге была ошибка в указании внутренней сети, проблему на самом деле полностью решить не удалось. Частично задача была решена созданием второго моста на этой карточке и указанием виртуалке использовать именно её. Таким образом, вопрос о том, почему проброс портов так и не заработал остался открытым... Спасибо всем откликнувшимся! |
||||||||||||||