networking basics
The following are the basics of networking, assuming a private, non-routable network of 192.168.1.0
The router address would be 192.168.1.1
The network subnet mask is 255.255.255.0
The broadcast ping address is 192.168.1.255
------------------------------------------------
The local system MUST have an internal loopback address of 127.0.0.1 and it MUST be in /etc/hosts
The local system's IP address will be assigned to the network interface: 192.168.1.22
------------------------------------------------
The network commands are: ifconfig, ping, route, hostname, traceroute, nslookup
------------------------------------------------
Configuration files are displayed in line below and are:
/etc/hosts - you can list local IP's in this file so that your system will resolve the name to the IP, useful if DNS fails
/etc/resolv.conf - this lists your name servers, if DHCP goes sideways or one of the many 'networking' tools burps, this will be empty - no resolution.
/etc/nsswitch.conf - this lists the order of services, typically for hosts it'll be files dns and sometimes compat
/etc/hostname - this is assignable at the command line by root
------------------------------------------------
the process to configure a NIC or Wireless is:
#################################################################################################################################
sudo ifdown wlan0 # must be root, or use sudo - turn the wireless interface down
sudo ifconfig wlan0 192.168.1.22 netmask 255.255.255.0 broadcast 192.168.1.255 # configure device name, IP, netmask, broadcast
sudo route add default gw 192.168.1.1 # add default gateway
#################################################################################################################################
ifconfig -a # did it take?
sudo ifup wlan0 # if it's not up, you've already given the configuration, use ifup to turn it up.
sudo route add default gw 192.168.1.1 # you may need to repeat the route command
sudo route # does it display correctly?
ifconfig -a # is it up now?
ping -c 3 192.168.1.1 # test local connectivity to router - if good, try going out on the net
ping -c 3 8.8.8.8 # if this works, you're golden, one more test to see if DNS is set,
nslookup distrowatch.org # if this resolves, /etc/resolv.conf is good
------------------------------------------------
------------------------------------------------
to record the information below I used "script":
------------------------------------------------
Luser@Linux-client [/home/Luser/
------------------------------------------------
--> script basic-networking.raw
Script started, file is basic-networking.raw
------------------------------------------------
Luser@Linux-client [/home/Luser/
------------------------------------------------
--> /sbin/ifconfig -a
eth0 Link encap:Ethernet HWaddr 12:34:56:f4:b9:5c
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)
Interrupt:20 Memory:ff9e0000-ffa00000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:27937 errors:0 dropped:0 overruns:0 frame:0
TX packets:27937 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2632803 (2.6 MB) TX bytes:2632803 (2.6 MB)
wlan0 Link encap:Ethernet HWaddr 98:76:54:05:09:80
inet addr:192.168.1.22 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: puke::ip6:c6ff:fe05:980/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:77750 errors:0 dropped:3 overruns:0 frame:0
TX packets:47534 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:84844934 (84.8 MB) TX bytes:5190438 (5.1 MB)
------------------------------------------------
Luser@Linux-client [/home/Luser/
------------------------------------------------
--> which ifconfig
/sbin/ifconfig
------------------------------------------------
Luser@Linux-client [/home/Luser/]
------------------------------------------------
--> route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.1.1 0.0.0.0 UG 0 0 0 wlan0
default * 0.0.0.0 U 1002 0 0 eth0
link-local * 255.255.0.0 U 0 0 0 eth0
192.168.1.0 * 255.255.255.0 U 0 0 0 wlan0
------------------------------------------------
Luser@Linux-client [/home/Luser/]
------------------------------------------------
--> ping -c 3 127.0.0.1 ; ping -c 3 192.168.1.22 ; ping -c 3 192.168.1.1 ; ping -c 3 8.8.8.8
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.033 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.036 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.032 ms
--- 127.0.0.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
rtt min/avg/max/mdev = 0.032/0.033/0.036/0.006 ms
PING 192.168.1.22 (192.168.1.22) 56(84) bytes of data.
64 bytes from 192.168.1.22: icmp_seq=1 ttl=64 time=0.029 ms
64 bytes from 192.168.1.22: icmp_seq=2 ttl=64 time=0.036 ms
64 bytes from 192.168.1.22: icmp_seq=3 ttl=64 time=0.035 ms
--- 192.168.1.22 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
rtt min/avg/max/mdev = 0.029/0.033/0.036/0.005 ms
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=4.76 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=3.09 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=4.75 ms
--- 192.168.1.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 3.098/4.207/4.769/0.786 ms
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=56 time=12.8 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=56 time=14.6 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=56 time=14.6 ms
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 12.881/14.044/14.627/0.822 ms
------------------------------------------------
Luser@Linux-client [/home/Luser/]
------------------------------------------------
--> traceroute 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
1 192.168.1.1 (192.168.1.1) 4.728 ms 4.676 ms 4.634 ms
2 96.120.100.13 (96.120.100.13) 19.350 ms 19.322 ms 23.799 ms
3 te-0-0-0-15-sur02.everett.wa.seattle.comcast.net (68.85.144.37) 23.762 ms 23.723 ms 23.683 ms
4 be-29-ar01.burien.wa.seattle.comcast.net (69.139.164.213) 26.828 ms 26.768 ms 26.744 ms
5 4.68.71.77 (4.68.71.77) 26.704 ms 26.636 ms 26.628 ms
6 ae-1-51.edge1.Seattle3.Level3.net (4.69.147.138) 26.573 ms ae-2-52.edge1.Seattle3.Level3.net (4.69.147.170) 16.398 ms ae-1-51.edge1.Seattle3.Level3.net (4.69.147.138) 16.317 ms
7 4.68.70.162 (4.68.70.162) 21.715 ms 13.458 ms 13.420 ms
8 72.14.233.19 (72.14.233.19) 20.198 ms 209.85.247.11 (209.85.247.11) 20.153 ms 72.14.232.114 (72.14.232.114) 22.951 ms
9 google-public-dns-a.google.com (8.8.8.8) 20.060 ms 20.009 ms 22.793 ms
------------------------------------------------
Luser@Linux-client [/home/Luser/]
------------------------------------------------
--> nslookup distrowatch.org
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
Name: distrowatch.org
Address: 82.103.136.226
------------------------------------------------
Luser@Linux-client [/home/Luser/]
------------------------------------------------
--> more /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8
nameserver 192.168.1.1
nameserver 8.8.4.4
search com net org us gov edu
------------------------------------------------
Luser@Linux-client [/home/Luser/]
------------------------------------------------
--> more /etc/hosts
127.0.0.1 localhost Linux-client
192.168.1.22 Linux-client # wireless
# 192.168.1.23 Linux-client# cable (uncomment when using CAT5)
192.168.1.33 superdawg # used for local system access)
192.168.1.39 oldblue # used for local system access)
8.8.8.8 nameserver # failover in case DNS quits, also list critical systems needed, but keep them up to date)
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
------------------------------------------------
Luser@Linux-client [/home/Luser/]
------------------------------------------------
--> more /etc/nsswitch.conf
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
passwd: compat
group: compat
shadow: compat
hosts: files dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
------------------------------------------------
Luser@Linux-client [/home/Luser/]
------------------------------------------------
--> more /etc/hostname
Linux-client
------------------------------------------------
Luser@Linux-client [/home/Luser/]
------------------------------------------------
--> exit
exit
------------------------------------------------
Script done on Mon 08 Jun 2015 08:07:16 PM PDT
------------------------------------------------
--> cat basic-networking.raw | col -b > basic-networking.html ; vi basic-networking.html
(net result, this file... deleted any errors, changed details to protect security and so on...)
|