Link to home
Start Free TrialLog in
Avatar of zenguru
zenguru

asked on

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.





Avatar of stermeau
stermeau

Could you post the output of the following commands ran on your fedora server:
   netstat -anpA inet | grep 8282
   iptables -L -n
Avatar of zenguru

ASKER


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.
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
Avatar of zenguru

ASKER


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.
ASKER CERTIFIED SOLUTION
Avatar of stermeau
stermeau

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zenguru

ASKER

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 ?
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.
Avatar of zenguru

ASKER

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.




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.
Avatar of zenguru

ASKER

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?