I am trying to set up a static IP address for my Debian virtual machines. In my /etc/networking/interfaces file I added:
iface ens33 inet static address 192.168.75.XXX gateway 192.168.0.1 netmask 255.255.255.0In the /etc/resolv.conf file I have added nameserver 8.8.8.8. I believe my issue is that unless I have the NetworkManager service enabled nothing shows up when I run route or ip route show. I tried adding a route to the routing table by running the following command: ip route add 192.168.75.0/24 via 192.168.75.XXX (my static ip) dev ens33. This populates the routing table and the table now looks like:
Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.75.0 0.0.0.0 255.255.255.0 U 0 0 0 ens33
When I run ping I still get the same error: "Destination Host Unreachable". How can I fix this?
42 Answers
In /etc/networking/interfaces, in each section, you set a netmask that defines the subnet your machine belongs to. Here: 255.255.255.0 means /24. IOW, the adresses on your subnet go from 192.168.75.1 to 192.168.75.254.
The gateway line specifies the address of the router that must be used to reach a machine that is outside that subnet. Obviously, the router must be a machine that is on the same subnet, i.e. that has an IP address between 192.168.75.1 to 192.168.75.254.
You have specified gateway 192.168.0.1. That means that the router is outside the subnet. That's why you cannot ping any machine outside your sub-network 192.168.75.0/24 ("Destination Host Unreachable").
You are using VMs. Your router is probably the IP address of your host. It depends on the configuration of your VM.
One last thing:
ip route add 192.168.75.0/24 via 192.168.75.XXX (my static ip) dev ens33is wrong. If you want to declare a router manually (as opposed to the interfaces file) then use this command:
ip route add default via 192.168.75.YYY (the IP of your router) dev ens33(default means "any address that has no known route")
Destination host unreachable is a common ICMP error message when the ping packets from your machine could not find the destination machine.
It looks like some settings on your machine are blocking the ping packets from discovering the route to the destination IP.
Well, I see you fixed the problem by changing the network type to bridge mode. So I think I better write a general answer since your issue is solved.
The common reason to get the ping reply Destination Host Unreachable is due to the overprotective settings on the firewall. Unless you are running a bridging firewall, a simple misconfiguration can block proper ping packet working.
You can verify it by disabling the firewall and ping the destination IP again.
The second common reason is a loose network connection. Referred from this source.
We can fix this, by disconnecting both power cables and Ethernet cables from the modem, router, and PC. Reconnect them again and power on the devices. It is called power cycling.