ajuda a entender o script e erro do roteador iptables

2

Olá, tenho este script de roteamento que estou usando, que é executado quando todas as interfaces de rede estão ativadas:

#!/bin/sh

PATH=/usr/sbin:/sbin:/bin:/usr/bin

#
# delete all existing rules.
#
iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -X

# Always accept loopback traffic
iptables -A INPUT -i lo -j ACCEPT


# Allow established connections, and those not coming from the outside
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -m state --state NEW -i ! wlan0 -j ACCEPT
iptables -A FORWARD -i wlan0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT

# Allow outgoing connections from the LAN side.
iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT

# Masquerade.
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

# Don't forward from the outside to the inside.
iptables -A FORWARD -i wlan0 -o wlan0 -j REJECT

# Enable routing.
echo 1 > /proc/sys/net/ipv4/ip_forward

wlan0 é a minha conexão wi-fi para os meus celulares android wi-fi, faixa de ip é 192.168.43.0/24 eth0 é minha conexão de rede local, faixa de ip: 10.1.1.0/24

Eu notei quando o script chegou a esta linha:

iptables -A INPUT -m state --state NEW -i ! wlan0 -j ACCEPT

Aparece o erro:

Bad argument 'wlan0'
Try 'iptables -h' or 'iptables --help' for more information.

Sendo um noob com iptables, não tenho certeza do que está errado.

Alguém poderia me esclarecer sobre isso?

    
por FortuneCookie101 20.01.2014 / 22:26

1 resposta

0

Para referência futura ou para qualquer pessoa que veja esta página, aqui está o script finalizado:

#!/bin/sh

PATH=/usr/sbin:/sbin:/bin:/usr/bin

#
# delete all existing rules.
#
iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -X

# Always accept loopback traffic
iptables -A INPUT -i lo -j ACCEPT

# Allow established connections, and those not coming from the outside
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -m state --state NEW ! -i wlan0 -j ACCEPT
iptables -A FORWARD -i wlan0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT

# Allow outgoing connections from the LAN side.
iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT

# Masquerade.
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

# Don't forward from the outside to the inside.
iptables -A FORWARD -i wlan0 -o wlan0 -j REJECT

#Port Forward Unifed remote
iptables -A INPUT -p tcp --dport 9512 -j ACCEPT -i wlan0
iptables -t nat -A PREROUTING -p tcp --dport 9512 -j DNAT --to-destination 10.1.1.12:9512
iptables -t nat -A POSTROUTING -d 10.1.1.12 -p tcp --dport 9512 -j SNAT --to-source 10.1.1.1

# Drop outside traffic except ssh
iptables -A INPUT -p tcp --dport ssh -j ACCEPT -i wlan0
iptables -A INPUT -j DROP -p tcp -i wlan0

# Enable routing.
echo 1 > /proc/sys/net/ipv4/ip_forward
    
por FortuneCookie101 15.05.2014 / 12:44