Articles of iptables

IPTables:NAT多个IP到一个公共IP

我正在寻找一种方法如何将2个或更多的内部IP地址(在我的情况下是xen dom)转换为一个外部IP地址。 我试图使用 iptables -t nat -A PREROUTING -d 123.123.123.123 -j DNAT – 到1.2.3.4 – 到1.2.3.7 iptables -t nat -A POSTROUTING -s 1.2.3.4 -j SNAT – 到123.123.123.123 iptables -t nat -A POSTROUTING -s 1.2.3.7 -j SNAT – 到123.123.123.123 并得到一个错误: iptables v1.4.14:DNAT:不支持多个目的地 试试`iptables -h'或'iptables –help'以获取更多信息。 我在手册中find了这个: 后来的内核(> = 2.6.11-rc1)不具备对多个范围进行NAT的能力。 所以我的问题是:为什么不可能了,是否有解决方法? 也许我应该使用其他我还不知道的方法? 编辑: 这个想法是使用像路由器一样的系统,所以我有一个地址,但有多个用户在后面。 问题是我不知道哪个连接受到用户的影响(例如1.2.3.4 )。 但是我知道,他们都有不同的端口可以打开stream量。 […]

postfix在iptables设置后不起作用

这是我的问题: # iptables -P INPUT DROP # host -t mx gmail.com ;; connection timed out; no servers could be reached # iptables -P INPUT ACCEPT # host -t mx gmail.com gmail.com mail is handled by 20 alt2.gmail-smtp-in.l.google.com. gmail.com mail is handled by 5 gmail-smtp-in.l.google.com. gmail.com mail is handled by 40 alt4.gmail-smtp-in.l.google.com. gmail.com mail is handled […]

我需要IPTABLES来启用IP FORWARDING吗?

为了简化,假设我连续使用3个服务器(全部运行centos 6.4) Internet—FW—LN—PN FW: firewall LN: login node PN: processing node 我可以从FW到世界ping,但不能从LN或PN。 我已启用IP FORWARDING并禁用LN中的IPTABLES: [root@meta ~]# !1005 cat /proc/sys/net/ipv4/ip_forward 1 [root@meta ~]# !1014 iptables –list Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination 所以我的问题是:如果我禁用iptables,IP转发工作? 或者我需要提高IPTABLES,并写出一个前瞻性的规则? 感谢-Ricardo

如何让iptables使用dhcp?

我的iptables规则阻止DHCP服务器到达虚拟机。 我如何允许DHCP 这里是我的iptables规则 # Generated by iptables-save v1.4.19.1 on Wed Sep 11 03:02:42 2013 *nat :PREROUTING ACCEPT [70:4483] :INPUT ACCEPT [6:400] :OUTPUT ACCEPT [23:2070] :POSTROUTING ACCEPT [27:3033] -A PREROUTING -i tun0 -p udp -m udp –dport 53 -j DNAT –to-destination 10.0.1.2 -A PREROUTING -i tun0 -p tcp -m tcp –dport 53 -j DNAT –to-destination 10.0.1.2 […]

iptables:如何将所有8443传入和传出redirect到443

所以我知道你需要先允许连接(对吧?) iptables -A INPUT -m state –state NEW -m tcp -p tcp –dport 8443 -j ACCEPT iptables -A INPUT -m state –state NEW -m tcp -p tcp –dport 443 -j ACCEPT 那么你需要设置redirect(对吧?) iptables -t nat -A PREROUTING -p tcp –dport 443 -j REDIRECT –to-ports 8443 那么也允许从8443的传出回应到443(对吧?) iptables -t nat -I OUTPUT -p tcp –dport 443 […]

如何修改iptables,以便在服务器上访问端口

当我做 curl –insecure https://localhost/svn 从我的Linux机器,我可以看到它正在返回一些数据 但是,当我在同一个networking,例如另一台机器上运行curl curl –insecure https://<serverip>/svn 我得到一个错误curl: (7) couldn't connect to host 即使我可以运行其他东西,如curl http://<serverip>:8080/或curl http://<serverip>:9090/ 有什么我可以用iptables做这个工作或别的东西吗? 这是我的iptables的样子: # iptables -L -n –line-numbers Chain INPUT (policy ACCEPT) num target prot opt source destination 1 ACCEPT all — 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 2 ACCEPT icmp — 0.0.0.0/0 0.0.0.0/0 3 ACCEPT all — 0.0.0.0/0 0.0.0.0/0 […]

我的iptableconfiguration是安全的?

我正在用iptables保护我的debian。 我这样做是为了允许ssh,http和https: # history | grep iptable 18 /sbin/iptables -A INPUT -m state –state ESTABLISHED -j ACCEPT 22 /sbin/iptables -I INPUT 2 -i lo -j ACCEPT 23 /sbin/iptables -A INPUT -p tcp -i eth0 –dport 22 -j ACCEPT 24 /sbin/iptables -A INPUT -p tcp -i eth0 –dport 80 -j ACCEPT 25 /sbin/iptables -A INPUT -p […]

在iptables中允许ssh

我正在做iptables防火墙configuration。 其实,我只需要从特定的IP只允许ssh连接。 但是,它阻止了SSH连接。 我使用了下面的命令。 sat:~# iptables -F sat:~# iptables -A INPUT -p tcp -s src_ip_address -d my_ip_address –dport 22 -m state –state NEW,ESTABLISHED -j ACCEPT sat:~# iptables -A INPUT -j DROP sat:~# iptables -nL Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT tcp — src_ip_address my_ip_address tcp dpt:22 state NEW,ESTABLISHED DROP all — […]

奇怪的邮件在maillog里,不能理解意思

所以我一直在战斗垃圾邮件从我们的服务器上周发送。 我们不断地在CBL上列出rDNS设置和DKIM签名。 在监视maillog时,我注意到以下几点: Dec 5 12:15:39 aneas postfix/smtp[16934]: A451C2215D7: to=<[email protected]>, relay=none, delay=84394, delays=84394/0.01/0/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=yourdomain.com type=MX: Host not found, try again) 所以我在邮件日志上运行了一个cat和grep,并且有很多这些条目和我注意到的这个时髦的一样: Dec 5 21:51:25 aneas postfix/smtpd[6217]: NOQUEUE: reject: RCPT from vxadg-29.srv.cat[46.16.59.162]: 450 4.1.1 <[email protected]>: Recipient address rejected: User unknown in virtual mailbox table; […]

如何允许Iptables的所有端口只用于本地ips除两个特定的端口

我正在寻找一种方法来允许我的debian服务器上的所有端口上的连接只有一个本地IP(192.168.2。*),除了两个特定的端口X和Y,应该允许任何IP。 如果IP不是本地IP,则除了端口X和Y之外的所有端口的所有连接都应该被阻塞。 我如何处理这种情况与Iptables?