kohler / click

The Click modular router: fast modular packet processing and analysis
Other
748 stars 321 forks source link

Fail to implement NAT on Click #223

Open PineUnion opened 8 years ago

PineUnion commented 8 years ago

I am sorry for bothering all of you. I am a newbie in Click. I have a problem with NAT router and need your help.

Here is my mazuNAT-based configuration:

client-VM----(Host only mode)------Click VM (mazuNAT)-----(Bridged Mode)------LAN router---outside (192.168.56.5)--------------(192.168.56.6)---------(39.115.19.135)-----------(39.115.19.254)
--------------------------------(08:00:27:42:97:a5)---(08:00:27:9e:0c:ac)------(00:e0:b1:8d:03:ab) In this scenario, both client-VM and Click VM are linux virtual machines (ubuntu) on VirtualBox. First of all, I set the internal interface of Click VM (192.168.56.6) as a default gateway of client-VM. To do this, I used a command on client-VM: $ sudo route add default gw 192.168.56.6

By the way, I hope that I can ping from client-VM to outside network through default gateway on Click VM. I also modified mazu-nat.click as following:


intern 192.168.56.6 192.168.56.0/24 08:00:27:42:97:a5, extern 39.115.19.135 39.115.19.128/25 08:00:27:9e:0c:ac, extern_next_hop 00:e0:b1:8d:03:ab intern_server 192.168.56.5


The rest of code is still remained. Then, I run mazu-nat.click on Click VM: $ sudo click-install mazu-nat,click

This command seems to work well. The problem is that client-VM is unreachable outside network when I make a ping on client-VM. So, Could anyone please tell me if I have misconfiguration or I should do something else?

Thank you very much!

ahenning commented 8 years ago

PineUnion, first apologies for not working through all the details in your post and hence I may have missed something, but what stands out to me is the "Host only" mode between the client and click VM's. I would use an internal network between the two virtual machines and enable promiscuous mode in the VirtualBox network settings.

PineUnion commented 8 years ago

Hi ahenning, Thank for your quick response! I also know that using internal network between two virtual machines is more suitable for my scenario. However, even I use internal network, it is still necessary to have a default gateway (for client-VM) on Click VM. Because my purpose is how to ping to outside network.

PineUnion commented 8 years ago

Has anyone ever done like this? Please help me. Thanks in advandce!

PineUnion commented 8 years ago

As Mr.Ahenning said, I also changed connection between two virtual machines from Host-only Network Mode to Internal Mode. My scenario is attached in this link: https://lh4.googleusercontent.com/-cZcJ2bqWHfw/Vl765UYanMI/AAAAAAAAAik/Qwe74DC_oa8/w1437-h272-no/abc.PNG

First of all, I also set the internal interface of Click VM (192.168.1.1) as a default gateway of client-VM. To do this, I used a command on client-VM: $ sudo route add default gw 192.168.1.1

By the way, I hope that I can ping from client-VM to outside network through default gateway on Click VM. I also modified mazu-nat.click as following:


intern 192.168.1.1 192.168.1.0/24 08:00:27:42:97:a5, extern 39.115.19.135 39.115.19.128/25 08:00:27:9e:0c:ac, extern_next_hop 00:e0:b1:8d:03:ab, intern_server 192.168.1.2


The rest of code is still unchanged. Then, I run mazu-nat.click on Click VM: $ sudo click-install mazu-nat.click

The problem is that NAT is still not working, even though I did not get any error. Could anyone please tell me if I have misconfiguration or I should do something else? I am sorry for bothering all of you. I tried to fix it some days but it is still nothing new.

ahenning commented 8 years ago

The default mazu-nat config does not support ping?

Config file comments: // Note that the configuration will only forward TCP and UDP through the // firewall. ICMP is not passed. A nice exercise: Add ICMP support to the // configuration using the ICMPRewriter and ICMPPingRewriter elements.

PineUnion commented 8 years ago

Thanks, Ahenning. I know this. I also try to send UDP packets from client-VM. I use WireShark to capture packets on Click-VM. Default gateway (192.168.1.1) received these packets but no packet can go through. Also, you mean that my scenario is correct, right?

ahenning commented 8 years ago

I don't see anything that suggests otherwise.

Just in case disable these on the click VM: /usr/local/sbin/ethtool --offload eth0 rx off /usr/local/sbin/ethtool --offload eth0 tx off /usr/local/sbin/ethtool --offload eth0 sg off /usr/local/sbin/ethtool --offload eth0 tso off /usr/local/sbin/ethtool --offload eth0 gso off /usr/local/sbin/ethtool --offload eth0 gro off /usr/local/sbin/ethtool --offload eth0 lro off

Also just in case enable promiscuous mode in VirtualBox network settings.

After that I would start debugging with "Print" elements in the click config to determine where in the config path the packet is lost. But I guess you know this.