For testmiljøet mitt vil jeg godta all innkommende trafikk, kan noen gi meg iptable-regelen som skal legges til.
Min nåværende iptables -L -n utgang ser slik ut
Kjede INPUT (policy ACCEPT) mål prot opt kilde destinasjon ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:8443 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:8080 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:9443 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:2124
Chain FORWARD (policy ACCEPT) target prot opt source destination REJECT all -- 0.0.0.0/0 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT) target prot opt source destinasjon
Takk
Kjør følgende. Det vil sette inn regelen øverst i iptables og vil tillate all trafikk med mindre den senere håndteres av en annen regel.
iptables -I INPUT -j ACCEPT
Du kan også skylle hele iptables-oppsettet ditt med følgende:
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
Hvis du spyler den, kan du kjøre noe sånt som:
iptables -A INPUT -i lo -j ACCEPT -m comment --comment "Allow all loopback traffic"
iptables -A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT -m comment --comment "Drop all traffic to 127 that doesn't use lo"
iptables -A OUTPUT -j ACCEPT -m comment --comment "Accept all outgoing"
iptables -A INPUT -j ACCEPT -m comment --comment "Accept all incoming"
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -m comment --comment "Allow all incoming on established connections"
iptables -A INPUT -j REJECT -m comment --comment "Reject all incoming"
iptables -A FORWARD -j REJECT -m comment --comment "Reject all forwarded"
Hvis du vil være litt tryggere med trafikken din, må du ikke bruke akseptere all innkommende regel, eller fjerne den med "iptables -D INPUT -j ACCEPT -m comment --comment "Accept all incoming ", og legge til mer spesifikke regler som:
iptables -I INPUT -p tcp --dport 80 -j ACCEPT -m comment --comment "Allow HTTP"
iptables -I INPUT -p tcp --dport 443 -j ACCEPT -m comment --comment "Allow HTTPS"
iptables -I INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT -m comment --comment "Allow SSH"
iptables -I INPUT -p tcp --dport 8071:8079 -j ACCEPT -m comment --comment "Allow torrents"
MERK: De må være over de to avvisningsreglene nederst, så bruk I for å sette dem inn øverst. Eller hvis du er anal som meg, bruk "iptables -nL --line-numbers" for å få linjenumrene, bruk deretter "iptables -I INPUT
Til slutt, lagre arbeidet ditt med:
iptables-save > /etc/network/iptables.rules #Or wherever your iptables.rules file is
for å akseptere all innkommende trafikk kan du bruke følgende kommando , -P er å sette standard policy som aksepter
iptables -P INPUT ACCEPT
hvis du ikke trenger de tidligere reglene dine, kan du bare slette/fjerne dem og deretter bruke kommandoen ovenfor.
for å tømme alle regler, bruk
iptables -F