wililupy / ubuntu-onie

14 stars 6 forks source link

Network is unreachable #3

Open LavanyaMalakalapalli opened 10 months ago

LavanyaMalakalapalli commented 10 months ago

image How to resolve

wililupy commented 10 months ago

Is your device getting it's IP settings via DHCP or are you trying to statically set the IP address? With DHCP it should "just work" out of the box. If you need to statically set the network, you can use ip commands:

ip link set eth0 up
ip addr add 192.168.1.10/24 dev eth0
ip route add default via 192.168.1.1

Just as a note, make sure you are using valid IP addresses and also that this setting will not persist reboots.

LavanyaMalakalapalli commented 10 months ago

if it is through DHCP,which commands I have to use if it is through statically setting IP address.........Can I give any valid IP address?

wililupy commented 10 months ago

For DHCP you can try to run dhclient to get a lease. If you are statically setting the IP address to get to your network, you need to use an IP address on the network address range. Otherwise you can use any address as long as your router (the route declaration above) can route traffic to where you need to. You can also look at your current network settings with ip addr to see what is currently configured. If you don't have any IP address, then either dhclient or the ip commands in my previous reply will get you going.

LavanyaMalakalapalli commented 10 months ago

image why still it is not working? image I have seen 10.0.2.2 is alias for 127.0.0.1.If 127.0.0.1 is working,then why not 10.0.2.2? image dhclient not found

wililupy commented 10 months ago

Good to see that ifconfig is available. Looking at that command I can see that the ip commands didn't put in the correct details. For ifconfig, you need to do the following commands to bring up your network. ALSO: Make sure you are using a valid network address range. I used 192.168.1.0 as an example, but you need to replace that with a valid network ip address and route for this to work correctly.

ifconfig eth0 up
ifconfig eth0 192.168.1.2 netmask 255.255.255.0
route add default gw 192.168.1.1

Looking at your ifconfig output from your first image, it looks like your device isn't getting an IP address and instead is using the APIPA address since it cannot receive an IP address from a DHCP server. As for the localhost address working, that is by design. 127.0.0.1 points to the lo device in the system. It allows the computer to use the network stack to talk to itself, but the 127.0.0.1 address is not routable which is why it cannot see outside of the world but can answer pings, since it is talking to itself.

Remember, use a valid IP address in your ifconfig settings. Talk to your network administrator for a valid IP address and netmask settings. You can also try to set a static IP address in your ping range, for example:

ifconfig eth0 up
ifconfig eth0 10.0.2.200 netmask 255.255.255.0

Just make sure that 10.0.2.200 is being used on the network otherwise you will have a bigger issue (Can't have two devices with the same IP address on the same network.) and that your netmask value is correct.

Hope this helps.

LavanyaMalakalapalli commented 10 months ago

image Still it is not working