게이트웨이로 아직 ping을 실행하지 않은 경우 게이트웨이나 인터넷 모두 ping할 수 없습니다.

게이트웨이로 아직 ping을 실행하지 않은 경우 게이트웨이나 인터넷 모두 ping할 수 없습니다.

나는 네트워킹을 처음 접했기 때문에 내 문제에 대한 응답을 찾으려고 노력했지만 찾지 못했습니다.

4개의 vm이 있는데 이를 1,2,3,4라고 부르겠습니다. 첫 번째(게이트웨이)에는 호스트 전용 및 브리지 네트워크 카드가 있고 나머지에는 호스트 전용 네트워크 카드만 있습니다.

VM의 2,3,4 패킷을 게이트웨이로 리디렉션하여 인터넷에 액세스할 수 있도록 몇 가지 iptables 규칙을 정했습니다. 작동했지만 게이트웨이나 8.8.8.8을 핑할 수 없습니다. 예를 들어 VM에 핑을 보내지 않는 한 첫 번째 항목(게이트웨이)은 이 작업을 수행한 후 gw, google 등을 ping할 수 있습니다. 그 전에는 로컬 컴퓨터에만 ping을 수행합니다. 나는 인터넷에 접속하여 GW와 ping을 하지 않고도 GW를 ping하고 싶습니다.

내가 정한 iptables 규칙은 다음과 같습니다.

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -A FORWARD -i enp0s8 -o enp0s3 -j ACCEPT
iptables -A FORWARD -i enp0s3 -o enp0s8 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A POSTROUTING -o enp0s3 -j MASQUERADE

첫 번째 VM의 인터페이스는 다음과 같습니다.

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo enp0s8
iface lo inet loopback
auto lo enp0s3
iface lo inet loopback

# The primary network interface
auto enp0s3
iface enp0s3 inet dhcp
auto enp0s8
iface enp0s8 inet static
        address 192.168.1.1
        netmask 255.255.255.0

내 다른 VM 중 하나가 있고 다른 VM도 동일하며 IP만 다릅니다.

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto enp0s3
iface enp0s3 inet static
        address 192.168.1.3
        netmask 255.255.255.0
        gateway 192.168.1.1

감사합니다! iptables -S를 입력하면 위의 마지막 규칙이 표시되지 않는 것이 정상인가요?

관련 정보