2

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.0

In 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?

4
  • 1
    do you have an internal router to route between .75.x and .0.x? your default gateway really should be an address on the IP network the the interface is on, or you need a route to reach it. if you don't have a router, those two IPs can't talk unless you open up the mask to 255.255.0.0 and treat all 192.168.x.y addresses as a single network. also, why are you trying to add a route for the local network? that is generally auto-detected. be more concerned about how to get from .75.x to .0.x. Commented Feb 15, 2021 at 21:45
  • So I have changed the gateway to be on the same ip network. I've changed it to 192.168.75.1 but also tried 192.168.75.0 but I still get the same results. Could this have to do with the Network configuration of the VM. I forgot to mention these are Virtual machines. I've tried the NAT and bridged connection but so far no change Commented Feb 18, 2021 at 17:23
  • do you have a router with an interface assigned the address 192.168.75.1, and an interface on 192.168.0.0/24? you can't just put in an address, it has to be an address on a router, with a pathway between both networks. If you don't have a router, just put your VMs in the 192.168.0.0/24 network. Personally I recommend using Bridged network connections unless you really want to get into the nitty-gritty of virtual networking, but you could make it work either way. Commented Feb 18, 2021 at 19:08
  • Hey thank you for all your help. I changed the network to 'bridged ' and i am now able to ping successfully. Thanks again for all your help. Commented Feb 18, 2021 at 19:18

2 Answers 2

0

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 ens33

is 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")

0

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.

You must log in to answer this question.

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