
Firstly STOP and START Networking service
Some people would argue restart would work, but I prefer STOP-START to do a complete rehash. Also if it’s not working already, why bother?
# /etc/init.d/networking stop [ ok ] Deconfiguring network interfaces...done. # /etc/init.d/networking start [ ok ] Configuring network interfaces...done.
STOP and START Network-Manager
If you have some other network manager (i.e. wicd, then start stop that one).
# /etc/init.d/network-manager stop [ ok ] Stopping network connection manager: NetworkManager. # /etc/init.d/network-manager start [ ok ] Starting network connection manager: NetworkManager.
Just for the kicks, following is what restart would do.. similar I still prefer stop/start combination.
# /etc/init.d/network-manager restart [ ok ] Stopping network connection manager: NetworkManager. [ ok ] Starting network connection manager: NetworkManager.
Now to bring up your interface:
# ifconfig eth0 up # ifconfig eth0 eth0 Link encap:Ethernet HWaddr aa:bb:cc:11:22:33 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Now lets set IP, subnet mask, broadcast address.
# ifconfig eth0 192.168.43.226 # ifconfig eth0 netmask 255.255.255.0 # ifconfig eth0 broadcast 192.168.43.255
Let check the outcome:
# ifconfig eth0 eth0 Link encap:Ethernet HWaddr aa:bb:cc:11:22:33 inet addr:192.168.43.226 Bcast:192.168.43.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:19325 errors:0 dropped:0 overruns:0 frame:0 TX packets:19641 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
and try to ping Google.com (cause if google.com is down, Internet is broken).
# ping google.com ping: unknown host google.com
Ah Internet is broken. Maybe not! So what went wrong in our side.
Simple, we didn’t add any default Gateway. Let’s do that
# route add default gw 192.168.43.1 eth0
and Just to confirm:
# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.43.1 0.0.0.0 UG 0 0 0 eth0 192.168.43.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
Looks good to me, lets ping google.com again:
# ping google.com PING google.com (119.30.40.16) 56(84) bytes of data. 64 bytes from cache.google.com (119.30.40.16): icmp_req=1 ttl=49 time=520 ms 64 bytes from cache.google.com (119.30.40.16): icmp_req=2 ttl=49 time=318 ms 64 bytes from cache.google.com (119.30.40.16): icmp_req=3 ttl=49 time=358 ms 64 bytes from cache.google.com (119.30.40.16): icmp_req=4 ttl=49 time=315 ms ^C --- google.com ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3002ms rtt min/avg/max/mdev = 315.863/378.359/520.263/83.643 ms
That’s it. Thanks for reading, do share.
Discover more from blackMORE Ops
Subscribe to get the latest posts sent to your email.
8 comments
works for me!
What about DNS? ;)
for DNS you can point to google DNS as shown below.
# echo “nameserver 8.8.8.8” >/etc/resolv.conf
Assuming you run Ubuntu with a DHCP capable router:
# echo “iface eth0 inet dhcp” >>/etc/network/interfaces
# ifup eth0
Job done mate.
But that’s DHCP! But yes a good idea nonetheless when you’re behind a DHCP server. Saves time and effort. Thanks Tomas for your suggestion.
# echo -e “iface eth0 inet dhcp\n address 10.1.1.2\n netmask 255.255.255.0\n gateway 10.1.1.1”>>/etc/network/interfaces && ifup eth0
my wifi connected to wifi router but no internet..if i use Lan cable,i got internet..
Great ! TY