Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 847
  • Last Modified:

networking between real and virtual hosts

I have LAN connecting 2 linux ( fedora and ubuntu)  machines via a DSL router/switch combo. I am able to connect to internet on both machines.

I have a local web application running in fedora:
http://localhost:8282/myproj and works fine and shows me program results when opening browser
with that address in fedora.

But when I enter the address:
.
http://192.168.1.34:8282/myproj in a browser in ubuntu host I get no connection error. 192.168.1.34 is ip address of fedora machine.  From ubuntu I can do ping 192.168.1.34 and works fine no packet loss.


Please tell me how do I make this connection to work in ubuntu?

In fedora I have setup virtual windows vista os (VM) as guest os using virtualbox and it works fine and I can connect to internet in windows vista vm. I used bridged networking option for network type setting for windows vista vm.

In windows vista VM I have the same problem with
http://192.168.1.34:8282/myproj  as i get not connection error in browser.
Also even ping 192.168.1.34 does not work in vista VM ( 100% packet loss).

How do I make above connection to work in VM ?  I know this is more advanced question than the first one.





0
zenguru
Asked:
zenguru
  • 5
  • 5
1 Solution
 
stermeauCommented:
Could you post the output of the following commands ran on your fedora server:
   netstat -anpA inet | grep 8282
   iptables -L -n
0
 
zenguruAuthor Commented:

netstat -anpA inet | grep 8282  does not generate any output but
netstat -anpA inet  gives lot of output but dont see 8282 in it.


 iptables -L -n  gives this:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination        
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0          
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0          
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           state NEW udp dpt:631
ACCEPT     udp  --  0.0.0.0/0            224.0.0.251         state NEW udp dpt:5353
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:631
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           state NEW udp dpt:631
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           state NEW udp dpt:161
REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination        
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           PHYSDEV match --physdev-is-bridged
REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination        




I hope this helps.
0
 
stermeauCommented:
ok, could you try with "netstat -anp | grep 8282" ?

Also your firewall is not accepting connections on port 8282.
Run the following to allow conections to port 8282:
iptables -I INPUT -p tcp --dport 8282 -m state --state NEW -j ACCEPT
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
zenguruAuthor Commented:

netstat -anp | grep 8282 gives me:
tcp        0      0 ::ffff:127.0.0.1:8282       :::*                        LISTEN      5586/java

I will wait your reply before typing the firewall related command in your post so that I dont mess something.
0
 
stermeauCommented:
Well, the netstat output tells you that your application is listening on 127.0.0.1 ( or localhost ).
In this case you application can only accept connections for the PC/server where it is instaleld.
You have to listen ( or bind ) to 192.168.1.34.
You should also allow the connection in the firewall with the command I gave you before.
0
 
zenguruAuthor Commented:
Thanks. How do I bind 192.168.1.34 so that my application can accept connection from any host on LAN or from guest os VM host ?
0
 
stermeauCommented:
It depends on you application...
If it is a standalone application you must have a call to a function like 'accept' or "listen".
You can also serach for "127.0.0.1" or "localhost" in the source code.
What programming language do you use?
Maybe you should post the code of your application.
0
 
zenguruAuthor Commented:
Sorry I should have made this clear before. The application is a java application running in tomcat webserver. It can be any simple JavaEE application based on Java servlet. For example it can be just  java servrlet doGet (handle http get request) method display message 'Hello World" when going to:
localhost:8282/myproj

Within my java application there is no reference to localhost or 127.0.0.1. I am using Intellij Idea IDE which allows me launch configuration of my java web application such as port number 8282 when I click Run or Debug. Intellij IDEA then passes this info to embedded tomcat server.

So still I am clueless. I thought there would be some linux commands that I enter to do the ip address binding instead of configuring locally running tomcat webserver in which I don have much background.
I execute the firewall related command but still same issue. In fedora I get the message hello world but any other host on LAN or VM host I get the no connection error.




0
 
stermeauCommented:
I don't know Intellij IDEA so I can't tell for sure maybe their is a parameter to tell tomcat to listen to a specific IP.
0
 
zenguruAuthor Commented:
When I change localhost to 192.168.1.34 in the tomcat  launch configuration for hostname in intellij IDEA and after using the command you gave:
iptables -I INPUT -p tcp --dport 8282 -m state --state NEW -j ACCEPT

then I am able to access the address :
http://192.168.1.34:8282/myproj  from ubuntu , VM and of course from fedora as well.
But now I cant access  http://localhost:8282/myproj from fedora because tomcat is now serving content on the ip address of fedora machine.

But I cant understand why localhost does not work. Some one has done this from googling but the intstructions were specific to IIS on Win XP and incomplete.

Also I dont know what is the implication of using the ip address of fedora machine as the address on which tomcat now serves the content. Does that mean I could use any local area network address for tomcat or for any locally running web server for that matter?








0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now