Centos 7.3에서 인터넷으로 라우팅

Centos 7.3에서 인터넷으로 라우팅

찾아보았지만 시도한 모든 것이 작동하지 않습니다.

Centos가 설치된 두 대의 컴퓨터가 있습니다.기계 1enp0s3( 192.168.56.99 IP), 그리고기계 2와 함께 (enp0s8 192.168.56.101그리고enp0s3 10.0.2.15 IPs). 보시다시피, 내 내부 네트워크는 이고 192.168.56.0/24, Machine 2를 통해 Machine 1을 인터넷에 연결하려고 합니다.

중요한 경우에는 Windows 10 호스트의 VirtualBox에서 실행되는 VM입니다.

어떻게 할 수 있나요? 감사해요.

답변1

iptables게이트웨이 머신의 친구가 되어야 합니다. 예를 들어 다음과 유사하게 구성됩니다.게이트웨이 설정을 위한 데비안 가이드eth0을 내부 네트워크 카드로 사용하고 eth1을 외부 주소로 사용하고 다음 스크립트를 제공합니다.

#!/bin/sh
# run as root

#
# 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 ! eth1 -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT

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

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

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

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

관련 정보