Ok, so I'm stumped. I have a new Raspbian install on a Model B Rev 2 and I can ssh using the IP Address just fine, but I can't connect on any other port outside the pi. Some details:
pi@dogwood:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 9.9 (stretch)
Release: 9.9
Codename: stretch
pi@dogwood:~ $
I am trying to write a python REST API, but to troubleshoot I am using the netcat command like so:
pi@dogwood:~ $ nc -l localhost 5001
While that is waiting for a connection, I run netstat in another terminal:
pi@dogwood:~ $ sudo netstat -lpnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 340/sshd
tcp6 0 0 :::22 :::* LISTEN 340/sshd
tcp6 0 0 ::1:5001 :::* LISTEN 11887/nc
pi@dogwood:~ $
Which I think means it has bound to all IPs and is listening on port 5001. That ::1:5001
looks suspicious, but I don't know enough about IPv6.
So from here, I can then do a
pi@dogwood:~ $ curl http://localhost:5001
^C
pi@dogwood:~ $
And it makes a connection. The IP address of the pi is:
pi@dogwood:~ $ ip address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enxb827ebe4d83d: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether SO:ME:MAC:HE:RE brd ff:ff:ff:ff:ff:ff
inet 192.168.2.11/24 brd 192.168.2.255 scope global enxb827ebe4d83d
valid_lft forever preferred_lft forever
inet6 fe80::f1bd:6ee:1851:66ba/64 scope link
valid_lft forever preferred_lft forever
pi@dogwood:~ $
pi@dogwood:~ $
However, if I use the ip address of the pi either locally on the pi:
pi@dogwood:~ $ curl http://192.168.2.11:5001
curl: (7) Failed to connect to 192.168.2.11 port 5001: Connection refused
pi@dogwood:~ $
or remotely, I get:
myuser@appletree:~$ curl http://192.168.2.11:5001
curl: (7) Failed to connect to 192.168.2.11 port 5001: Connection refused
myuser@appletree:~$
So obviously it's a firewall... right? Except that iptables has no rules:
pi@dogwood:~ $ sudo iptables -S
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
pi@dogwood:~ $
And ufw
is not installed:
pi@dogwood:~ $ sudo ufw
sudo: ufw: command not found
pi@dogwood:~ $
Any suggestions?