0

I've 3 machines :

  • 1 server with LAN card without internet direct access
  • 1 Windows host with WiFi connection for Internet and 1 LAN port
  • 1 linux virtual machine on the Windows host

[Server_without_internet]---[Linux_VM]---[Windows_host]

  • Server_without_internet : eth0 -> 192.168.1.1
  • Linux_VM_WiFi_NAT : wlan0 -> 10.0.2.15
  • Linux_VM_LAN_bridge_card : eth0 -> 192.168.1.254
  • Windows_LAN : 192.168.1.2
  • Windows_WiFi : 172.16.1.1 / 10.0.2.1(NAT Linux to 10.0.2.15)

I want to use iptables forwarding to have Internet access to [Server_without_Internet].

Routes :

  • Server_without_internet, Linux_VM_LAN_bridge_card, Windows_LAN : 192.168.1.0/24 via 192.168.1.254
  • Linux_VM_WiFi_NAT : 0.0.0.0 via 10.0.2.1 (172.16.1.1)

I enable IPv4 forwarding :

sysctl -w net.ipv4.ip_forward=1

I configure iptables to Linux_VM same as :

iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE 
iptables -A FORWARD -i wlan0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth0-o wlan0 -j ACCEPT

Ping :

  • Ping OK : 192.168.1.1 to 1.2
  • Ping OK : 192.168.1.1 to 1.254
  • Ping OK : 192.168.1.2 to 1.1
  • Ping OK : 192.168.1.2 to 1.254
  • Ping OK : 192.168.1.254 to 1.1
  • Ping OK : 192.168.1.254 to 1.2
  • Ping OK : 10.0.2.15 to 8.8.8.8
  • Ping OK : 172.16.1.1 / 10.0.2.1 to 8.8.8.8
  • Ping KO : 192.168.1.1 to 8.8.8.8

Remind I try to have internet access since [Server_without_server] via [Linux_VM]

When I check with tcpdump on Linux_VM:

  • tcpdump -i eth0 -vvnn : I see the echo request to 8.8.8.8
  • tcpdump -i wlan0 -vvnn : I see the echo request to 8.8.8.8 but not echo reply

So the eth0 forwarding to wlan0 with iptables work but I not have the return.

Someone have an idea ?

Thanks

EDIT

I add the conntrack iptables cli and the IP public icmp test work.

iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 

Now the DNS resolver doesn't work. In the server /etc/resolv.conf, I had Google DNS and OpenDNS DNS.

An idea ?

THanks

  • Which kind of virtual machine platform di you use? Does it offer ICMP on its networking? Eg virtualbox with "user mode" networking doesn't. – Ralph Rönnquist Feb 8 at 0:17
  • @Ralph : Virtualbox yes, but also wget doesn't work Do I have to install a local dns on the Linux (Linux_VM) server and use this one on my server (server_without_internet)? – Itrix Feb 8 at 8:08
  • Now the DNS resolver doesn't work. In the server /etc/resolv.conf, I had Google DNS and OpenDNS DNS. – Itrix Feb 8 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.