
Unten sind die iptable-Firewall-Regeln aufgeführt, die ich in meinem CentOS-System habe. Zu diesem Zeitpunkt konnte ich localhost nicht anpingen. ping localhost
Es ist fehlgeschlagen.
Aber sobald ich iptables -F
die Regeln geleert hatte, konnte ich localhost anpingen. Die Frage ist WARUM?? Wie wirkte sich dieser iptables-Satz auf die Funktionalität des Anpingens von localhost (127.0.0.1) aus?
root@localhost:~# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:53
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:53
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:67
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:67
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:6080
LPASS udp -- 0.0.0.0/0 0.0.0.0/0 state NEW udp spt:68 dpt:67
LPASS all -- 192.168.122.49 0.0.0.0/0
LPASS tcp -- 192.168.122.0/24 0.0.0.0/0 tcp spt:21
LPASS all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
LPASS tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:21
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state NEW
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpts:8505:8506
LPASS tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:443
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:6000
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpts:6001:6100
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 state NEW udp dpt:161
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:24
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:8081
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:2222
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
LDROP all -- 0.0.0.0/0 0.0.0.0/0
Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 192.168.122.0/24 ctstate RELATED,ESTABLISHED
ACCEPT all -- 192.168.122.0/24 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
ACCEPT tcp -- 0.0.0.0/0 192.168.122.49 tcp dpt:3389
ACCEPT all -- 192.168.122.49 0.0.0.0/0
DROP all -- 192.168.122.0/24 0.0.0.0/0
LFDROP all -- 0.0.0.0/0 0.0.0.0/0 PHYSDEV match --physdev-in vnet+ --physdev-out vnet+ --physdev-is-bridged
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state NEW
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:68
Chain LDROP (1 references)
target prot opt source destination
DROP all -- 0.0.0.0/0 0.0.0.0/0
Chain LFDROP (1 references)
target prot opt source destination
DROP all -- 0.0.0.0/0 0.0.0.0/0
Chain LPASS (6 references)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ifconfig zeigt an, dass die Schnittstelle aktiv ist.
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 65922 bytes 5788036 (5.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 65922 bytes 5788036 (5.5 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Antwort1
Das ist weilalleswas aus einer Schnittstelle herausgeht und in eine Schnittstelle hineingeht, wird über die Iptables oder die Firewall-Regeln analysiert.
Wenn also ein Paket von einer Schnittstelle zu sich selbst gehen muss, sei es für ICMP, HTTP, FTP oder ein anderes Protokoll, wird es denselben Prozess durchlaufen wie im Fall einer externen IP. Im Fall von HTTP wird beispielsweise eine TCP-Verbindung gestartet und dann eine HTTP-Anfrage an den lokalen Host gesendet. Die gesamte Kommunikation erfolgt über diesieheSchnittstelle.
Nun machen Sie zum Beispiel einenAUSGABERegel wie folgt:
ACCEPT ICMP -- 127.0.0.1 127.0.0.1
und versuchen Sie, ICMP auszuführen. Es würde trotzdem nicht funktionieren. Sie benötigen außerdem eine Eingaberegel wie die folgende, damit es funktioniert:
ACCEPT ICMP -- 127.0.0.1 127.0.0.1