Pinging a static IP Address from Pi - ip

I was pinging a device with a fixed IP Address from my raspberry pi with this code:
response = os.system("ping -c 1" + hostname)
it was working until lately(probably after upgrading the pi) I am getting:
network unreachable
or
ip not available
eventhough the device is there. There is no problem with the hardware and I have set a static IP address on the pi by editing /etc/dhcpcd.conf
any help ?

It got resolved by resetting the pi to its default settings.

Related

Can ping 8.8.8.8 but not other IP

We have some networking issue on a Raspberry Pi and a 4G dongle. The same buildroot image on other Raspberry Pi with another 4G dongle is working fine. However on this Raspberry Pi + dongle setup:
PPP can establish connection and create a ppp0 interface
Can ping 8.8.8.8
When ping google.com, it can find IP address, but ping cannot go through, with 100% failure.
Directly ping the found google.com IP also failed. Tried other domain names and IP as well. Internet like HTTP are also not working.
In /etc/resolv.conf, the nameserver looks correct, it is in same network as the ppp0 IP assigned by ISP. Anyway if the "ping google.com" can find IP address, I think the DNS is working fine.
routing table is also correct, there is only ppp0 routes in the table.
My question is, what could be the root cause of this issue and how to solve it? Or what test do you suggest for me to identify the root cause? Thanks!
It terms out that the APN we use is a Shared Internet APN rather than a public APN, which means The service provider only whitelists some IP addresses for us to access with this APN.

Can not SSH or PING RasPi3B+ IP address

I have a Raspberry Pi 3B+ which I have to admit has only recently shown this problem.
I booted up the Pi normally and tried to SSH into it since I have a static IP set for it. This was unsuccesful, so I connected my monitor and keyboard, and run ifconfig to see the current IP address. After checking to see if my laptop is connected to the same WiFi network as the Pi, I tried SSH-ing into the Pi with no success: sh: connect to host xxx.xxx.xxx.xxx port 22: Connection timed out or Reply from xxx.xxx.xxx.xxx: Destination host unreachable..
My Pi has the SSH interface option enabled and can use it's internet connectivity as I could PING www.google.com with success and can also run sudo apt update && sudo apt upgrade.
I tried rebooting thinking this is a power issue, using a different socket / charger, restarting dhcpcd.service. No success, so I got curious.
I have connected a WiFi dongle onto the Pi, enabling the wlan1 interface which immediately discovered and connected to the WiFi network (it is an open network) and was assigned an IP. SSH=ing into this IP was successful. How can I fix my wlan0 interface? I do not want to rely on an external dongle. Connecting an ethernet cable and SSH-ing using the eth0 interface works as well.
I ended up reflashing my RaspberryPi with a fresh install

ipv4 address vs localhost

if our system IP address acts as a local host, then what does this definition indicates for IP address of localhost - "127.0. 0.1 is the loopback Internet protocol (IP) address also referred to as the localhost"
Within a network every device has it's own ip address. The ip address of a device is for every device different and May change (DHCP).
The hostname loclalhost respectively the ip address 127.0.0.1 points always on the current device.
For example If you are using a laptop and ping from that laptop to 127.0.01 it will resolve to the device the ping is send from thus the laptop itself.
If you ping from a server, it will resolve to the device the ping is send from thus the server.

CentOS - Wrong automatic ifconfig broadcast address

Running a Centos 5.11 machine with two network cards.
One is facing the internal network (private IP), the other the Internet (public IP).
Because we had some issues lately with it (ARP collision - but that's not the point here!), I started verifying its config. And I find out the broadcast set for the public IP is wrong.
IP is xxx.xxx.xxx.25
Subnet is 255.255.255.240
So basically we should have:
Network xxx.xxx.xxx.16
First IP xxx.xxx.xxx.17
Last IP xxx.xxx.xxx.30
Broadcast xxx.xxx.xxx.31
But the broadcast is automatically set to last host xxx.xxx.xxx.30
If I change it using command line, it is reseted back to the same IP once I do a service network restart...
I had to edit /etc/sysconfig/network-scripts/ifcfg-eth0 for the broadcast to stick to what I wanted.

dnsmasq resolve DNS queries normally

I'm new to dnsmasq and networking isn't my strong point, hopefully i'm missing something simple.
I have a Ubuntu laptop running dnsmasq. The laptop's WiFi is connected to the Internet, the laptop's ethernet is connected to a LAN.
Plugging my machine into the LAN I am assigned an IP address by the laptop. Accessing www.google.com on my machine gets picked up the laptop and i'm served the laptops Apache page, which is my desired result. The problem is I can't access any other website, Destination Host Unreachable.
I'd like the laptop running dnsmasq to allow my machine to resolve DNS queries normally and only be restricted when accessing www.google.com.
My dnsmasq.conf is the default except:
address=/www.google.com/192.168.0.1
interface=eth0
dhcp-range=192.168.0.50,192.168.0.150,12h
I've a feeling it might be related to the IP settings on each network?
The WiFi has a static IP 192.168.1.55 taking to the router at 192.168.1.1 and the DNS server at 192.168.1.10.
The ethernet is configured manually with an IP 192.168.0.1 setting the router as the WiFi IP 192.168.1.55 and the same for the DNS server 192.168.1.55.
Thanks in advance for any help.
Pete
After a lot of fiddling, this was related to iptables and not dnsmasq.

Resources