Wireless Army
This is a blog / tips and tricks website for web developers and security researchers.
follow us in feedly


connect: Network is unreachable
by admin
 at 2017-04-09 00:24:00.

In this article we will show you how to give an static ip to a linux box.

if you are trying to set an static ip address you may get an error like this:

connect: Network is unreachable

if you notice you can pin computers on the network but not websites.

all you need to do is run this command and it should would:

route add default gw 192.168.1.1

and if you may had other problems we will go trough how to do it

assuming you have your router set up like this:

router ip: 192.168.1.1

subnetmask: 255.255.255.0

you need to open the file /etc/network/inerfaces

and comment out these two lines

allow-hotplug eth0
iface eth0 inet dhcp

to

#allow-hotplug eth0
#iface eth0 inet dhcp

and add the fallowing line (assuming you want to have the ip address 192.168.1.15)

auto eth0 #to run on start up
iface eth0 inet static #tel it to be static
address 192.168.1.15 #the ip addess that you want to have
netmask 255.255.255.0 #subnetmask
gateway 192.168.1.1 #the ip address of your router
broadcast 192.168.1.255

and for the dns you need to edit the file /etc/resolv.conf

nameserver 192.168.1.1 #your routers dns
nameserver 8.8.4.4 #or you can use googles dns

and filnally:

Now you can restart the computer or just run this command

sudo /etc/init.d/networking restart

if you want to get back to dhcp dynamic ip you can just run

dhclient

if you had any more problems you can comment below and I would be more that happy to help