LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-07-2014, 08:26 AM   #1
mecheri
LQ Newbie
 
Registered: Apr 2014
Posts: 2

Rep: Reputation: Disabled
IP Forwarding


Hi everyone,


I have installed kvm on my ubuntu pc.
I have created 3 VMs, two on the 192.168.122.0 network and one on the 192.168.100.0 network.


When a packet comes from 192.168.100.190 (outside.example.org) and goes to the 192.168.122.0/24 network.
The 2 VMs (server.example.com and client.example.com) see it as coming from 192.168.122.1 and NOT from 192.168.100.190 as expected !!


Examples:


- When I run a ping command from 192.168.100.190 (outside.example.org) the output of the tcpdump command on 192.168.100.103 shows this:


# tcpdump -i eth0 -v icmp
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
14:40:57.249450 IP (tos 0x0, ttl 63, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
192.168.122.1 > server.example.com: ICMP echo request, id 13, seq 1, length 64



- When I send an http client request (elinks browser) from 192.168.100.190 to the httpd server on 192.168.100.103 the logs file on this shows :


192.168.122.1 - - [06/Apr/2014:14:39:43 +0200] "GET / HTTP/1.1" 200 17


Any idea ?
 
Old 04-07-2014, 12:12 PM   #2
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
192.168.122.1 - that would be the ip of kvm host,right? Or is it some other router configured here?
It sounds to me as NAT is being used. If you don't want that between your 192.168.122.1 private networks you'll have to configure the device with ip 192.168.122.1 .
 
Old 04-08-2014, 04:21 AM   #3
mecheri
LQ Newbie
 
Registered: Apr 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
Hi,

Thanks for your reply.

192.168.122.1 is the IP of the first virtual interface of the kvm host.

eth0 inet addr:192.168.1.26 Bcast:192.168.1.255 Mask:255.255.255.0
virbr0 inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
virbr1 inet addr:192.168.100.1 Bcast:192.168.100.255 Mask:255.255.255.0

>>It sounds to me as NAT is being used.
Yes it is

*nat
:PREROUTING ACCEPT [960:118740]
:INPUT ACCEPT [594:90857]
:OUTPUT ACCEPT [3190:201902]
:POSTROUTING ACCEPT [3515:222655]
-A POSTROUTING -s 192.168.100.0/24 ! -d 192.168.100.0/24 -p tcp -j MASQUERADE --to-ports 1024-65535
-A POSTROUTING -s 192.168.100.0/24 ! -d 192.168.100.0/24 -p udp -j MASQUERADE --to-ports 1024-65535
-A POSTROUTING -s 192.168.100.0/24 ! -d 192.168.100.0/24 -j MASQUERADE
-A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -p tcp -j MASQUERADE --to-ports 1024-65535
-A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -p udp -j MASQUERADE --to-ports 1024-65535
-A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -j MASQUERADE
COMMIT


>> If you don't want that between your 192.168.122.1 private networks you'll have to configure the device with ip 192.168.122.1

Sorry I don't get it ! what do you mean ? which device ?
 
Old 04-09-2014, 12:37 PM   #4
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
Now I don't quite understand you.
You are using NAT, you have obviously set it up yourself. But you don't want NAT? Well then remove those rules.

Maybe you don't really know what NAT is:
When NAT is used on a router/firewall, it takes the actual incoming IP and translates it to it's own.
That's how you can use private ip's on your server and still have it reachable from internet.
So, your NAT rules will replace the senders ip with routers ip. That's why you get 192.168.122.1 in the logs.

Or maybe I completely misunderstand you?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ip forwarding with iptables - double forwarding with openVPN?? sousacanfly Linux - Networking 8 01-20-2014 08:49 AM
Shorewall: port forwarding problem, port is closed even after forwarding Synt4x_3rr0r Linux - Networking 2 12-13-2009 04:36 PM
Mail Forwarding in postfix/maildrop/redhat (like yahoo mail forwarding) topcat Linux - Software 1 08-31-2007 12:10 PM
Simple Port Forwarding Firewall - not forwarding MadTurki Linux - Security 14 04-09-2006 12:08 PM
port forwarding and packet forwarding syrtsardo Linux - Newbie 2 07-03-2003 10:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration