-1

I have made 2 webapps(I'm learning web development basics). One using ruby-on-rails and another using apache2.

My laptop's local IP is 192.168.122.1.

The following 2 urls are working on my machine : 1) The ROR webapp -> http://192.168.122.1:3000 2) The Apache2 App -> http://192.168.122.1

However, when I type the same URLs on another device/machine on the LAN,I get ERR_CONNECTION_REFUSED.

When I type into the terminal the following : sudo nc -v 192.168.122.1 3000 , I get the message Connection to 192.168.122.1 3000 port [tcp/*] succeeded!.

I don't think that this is a problem with rails or apache2 but is either a bug in Ubuntu OS or there's something about opening ports which I don't understand. I tried opening the necessary ports 80 & 3000 using ufw but didn't get the desired results. I tried completely disabling the firewall(not a good practice, of course) by typing sudo ufw disable. But,it had no effect. I'm still facing the same problem.

I'm using Ubuntu 16.04. I had developed a basic web app almost 4 years ago on Ubuntu 12.04 and never had to face such issues.

Iptables:

umangmathur@Acer-Aspire-V3-571:~$ sudo iptables -L
[sudo] password for umangmathur: 
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:3000
ACCEPT     udp  --  anywhere             anywhere             udp dpt:domain
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:domain
ACCEPT     udp  --  anywhere             anywhere             udp dpt:bootps
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:bootps
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             192.168.122.0/24     ctstate RELATED,ESTABLISHED
ACCEPT     all  --  192.168.122.0/24     anywhere            
ACCEPT     all  --  anywhere             anywhere            
REJECT     all  --  anywhere             anywhere             reject-with icmp-port-unreachable
REJECT     all  --  anywhere             anywhere             reject-with icmp-port-unreachable

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     udp  --  anywhere             anywhere             udp dpt:bootpc

Ifconfig:

umangmathur@Acer-Aspire-V3-571:~$ ifconfig
enp2s0f0  Link encap:Ethernet  HWaddr b8:88:e3:0b:04:c4  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:16 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:15396 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15396 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1646030 (1.6 MB)  TX bytes:1646030 (1.6 MB)

virbr0    Link encap:Ethernet  HWaddr 00:00:00:00:00:00  
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlp3s0    Link encap:Ethernet  HWaddr 08:3e:8e:2a:10:81  
          inet addr:192.168.43.129  Bcast:192.168.43.255  Mask:255.255.255.0
          inet6 addr: fe80::99e9:db42:eceb:a526/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:544441 errors:0 dropped:0 overruns:0 frame:0
          TX packets:302249 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:710738799 (710.7 MB)  TX bytes:46367641 (46.3 MB)

List of listening ports(using netstat):

umangmathur@Acer-Aspire-V3-571:~$ sudo netstat -patune | grep LISTEN
[sudo] password for umangmathur: 
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      123        23438       1110/mysqld     
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN      0          31251       2361/smbd       
tcp        0      0 127.0.1.1:53            0.0.0.0:*               LISTEN      0          26992       1508/dnsmasq    
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      0          27672       1406/dnsmasq    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      0          233420      1082/sshd       
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      0          23217       923/cupsd       
tcp        0      0 192.168.122.1:3000      0.0.0.0:*               LISTEN      1000       71774       4678/192.168.122.1:
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN      0          31250       2361/smbd       
tcp6       0      0 :::139                  :::*                    LISTEN      0          31249       2361/smbd       
tcp6       0      0 :::80                   :::*                    LISTEN      0          28945       1861/apache2    
tcp6       0      0 :::22                   :::*                    LISTEN      0          233422      1082/sshd       
tcp6       0      0 ::1:631                 :::*                    LISTEN      0          23216       923/cupsd       
tcp6       0      0 :::445                  :::*                    LISTEN      0          31248       2361/smbd       
2
  • Please add the list of listening ports too: netstat -patune | grep LISTEN
    – ThoriumBR
    Sep 8, 2017 at 18:02
  • @ThoriumBR Edited the question to include the list of listening ports. Sep 8, 2017 at 18:12

2 Answers 2

2

Looks your applications are listening on virbr0, and that is a virtual bridge interface used for NAT on some virtualized environments.

If you are running on your physical computer, the applications should bind to 192.168.43.129 or to 0.0.0.0.

If you are running on a virtualization environment (VirtualBox, Qemu, VMWare), you will have to create a bridge interface, or create a port redirect rule.

1

Your laptop's IP is actually:

wlp3s0    Link encap:Ethernet  HWaddr 08:3e:8e:2a:10:81  
      inet addr:192.168.43.129  Bcast:192.168.43.255  Mask:255.255.255.0
      inet6 addr: fe80::99e9:db42:eceb:a526/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:544441 errors:0 dropped:0 overruns:0 frame:0
      TX packets:302249 errors:0 dropped:0 overruns:0 carrier:0

Look at the RX & TX packets.

Not the answer you're looking for? Browse other questions tagged .