Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've got ubuntu box with nat. Here is the problem:

root@office.redhelper.ru:~# tcpdump -i tap0 host 194.190.8.141 -n
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on tap0, link-type EN10MB (Ethernet), capture size 65535 bytes
13:20:51.764584 IP 10.3.67.118.5060 > 194.190.8.141.37037: SIP, length: 407
13:20:51.798804 IP 37.230.221.243.48284 > 194.190.8.141.37037: UDP, length 2

Packets to the same destination have different source addresses. Both 10.3.67.118 and 37.230.221.243 belong to the same machine. In this test packets originate from different machines that forward packets through this one (office.redhelper.ru). Here are some configs:

root@office.redhelper.ru:~# route -n | grep 194.190.8.141
194.190.8.141   37.230.221.254  255.255.255.255 UGH   0      0        0 tap0

root@office.redhelper.ru:~# ifconfig
eth0      Link encap:Ethernet  HWaddr d4:3d:7e:04:eb:93
          inet addr:10.3.67.118  Bcast:10.3.67.255  Mask:255.255.255.0
          inet6 addr: fe80::d63d:7eff:fe04:eb93/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1959108842 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1950454520 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1412305826151 (1.4 TB)  TX bytes:944769678190 (944.7 GB)
          Interrupt:41 Base address:0xc000

eth1      Link encap:Ethernet  HWaddr 00:09:3b:f0:1a:40
          inet addr:10.0.0.10  Bcast:10.0.0.255  Mask:255.255.255.0
          inet6 addr: fe80::209:3bff:fef0:1a40/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1400  Metric:1
          RX packets:49570 errors:0 dropped:0 overruns:0 frame:0
          TX packets:53330 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:8179658 (8.1 MB)  TX bytes:12049794 (12.0 MB)

eth2      Link encap:Ethernet  HWaddr 64:70:02:01:52:97
          inet addr:192.168.1.254  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::6670:2ff:fe01:5297/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:113424711 errors:0 dropped:0 overruns:0 frame:0
          TX packets:113714020 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:88903198346 (88.9 GB)  TX bytes:88413955024 (88.4 GB)
          Interrupt:40 Base address:0xe000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:137423 errors:0 dropped:0 overruns:0 frame:0
          TX packets:137423 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:16203037 (16.2 MB)  TX bytes:16203037 (16.2 MB)

tap0      Link encap:Ethernet  HWaddr e2:0b:0b:64:e1:9a
          inet addr:37.230.221.243  Bcast:37.230.221.255  Mask:255.255.255.240
          inet6 addr: fe80::e00b:bff:fe64:e19a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:69999264 errors:0 dropped:0 overruns:0 frame:0
          TX packets:91116830 errors:0 dropped:17014 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:5994733647 (5.9 GB)  TX bytes:104066589815 (104.0 GB)

root@office.redhelper.ru:~# iptables -nvL -t nat
Chain PREROUTING (policy ACCEPT 39771 packets, 2590K bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain INPUT (policy ACCEPT 210 packets, 21189 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 407 packets, 32556 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
39631 2456K MASQUERADE  all  --  *      *       0.0.0.0/0            0.0.0.0/0

What may cause this problem?

Update: The problem is that some packets that are forwarded through tap0 using nat have have source ip of eth0 and not tap0.

Update2: Packets come to eth2:

14:44:00.753456 IP (tos 0x0, ttl 64, id 3479, offset 0, flags [none], proto UDP (17), length 435)
    192.168.1.184.5060 > 194.190.8.141.37037: [udp sum ok] SIP, length: 407
14:44:01.068893 IP (tos 0x0, ttl 64, id 5495, offset 0, flags [DF], proto UDP (17), length 30)
    192.168.1.201.46934 > 194.190.8.141.37037: [udp sum ok] UDP, length 2

And then get forwarded to tap0 as follows:

14:44:00.753478 IP (tos 0x0, ttl 63, id 3479, offset 0, flags [none], proto UDP (17), length 435)
    10.3.67.118.5060 > 194.190.8.141.37037: [udp sum ok] SIP, length: 407
14:44:01.068912 IP (tos 0x0, ttl 63, id 5495, offset 0, flags [DF], proto UDP (17), length 30)
    37.230.221.243.46934 > 194.190.8.141.37037: [udp sum ok] UDP, length 2
share|improve this question
    
What problem? You never explained what the problem is. –  David Schwartz Jun 7 '13 at 9:30
    
@DavidSchwartz Well if packet with source ip 10.3.67.118 goes to the internet I will never receive any reply –  Poma Jun 7 '13 at 9:35
    
@DavidSchwartz The goal is to make all packets that go through tap0 to get source ip of tap0 (37.230.221.243) –  Poma Jun 7 '13 at 9:38
    
So all of your traffic should be routed through tap0, and should be masqueraded, correct? –  NickW Jun 7 '13 at 9:49
    
@NickW almost. All traffic to 194.190.8.141 should, but for other hosts the gateway is different. –  Poma Jun 7 '13 at 9:55
show 7 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.