Showing posts with label Linux Networking. Show all posts
Showing posts with label Linux Networking. Show all posts

Friday, August 30, 2013

Basic configuraton --- Linux networking

Linux Box booted up, but no networking. Frustrated......
First check the following tools:

bash-3.2# ls /sbin/arp
/sbin/arp
bash-3.2# ls /sbin/ifconfig
/sbin/ifconfig
bash-3.2# ls /sbin/route
/sbin/route

What's the output:
bash-3.2# ifconfig
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.255.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  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:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

bash-3.2# arp -a
bash-3.2# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
bash-3.2#
Nothing useful...........; Try the following commands:

bash-3.2# ifconfig eth0 192.168.70.245 netmask 255.255.248.0 up
bash-3.2# route add default gw 192.168.64.1
bash-3.2# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:A0:C9:00:00:02
          inet addr:192.168.70.245  Bcast:192.168.71.255  Mask:255.255.248.0
          inet6 addr: fe80::2a0:c9ff:fe00:2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:390 (390.0 b)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.255.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  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:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

bash-3.2# ping 192.168.66.157
PING 192.168.66.157 (192.168.66.157) 56(84) bytes of data.
64 bytes from 192.168.66.157: icmp_seq=1 ttl=64 time=10.1 ms
64 bytes from 192.168.66.157: icmp_seq=2 ttl=64 time=0.292 ms
64 bytes from 192.168.66.157: icmp_seq=3 ttl=64 time=0.288 ms
64 bytes from 192.168.66.157: icmp_seq=4 ttl=64 time=0.287 ms
^C
--- 192.168.66.157 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3008ms
rtt min/avg/max/mdev = 0.287/2.753/10.145/4.267 ms
bash-3.2# arp
Address                  HWtype  HWaddress           Flags Mask            Iface
192.168.66.157            ether   00:0e:1e:0b:18:c0   C                     eth0

bash-3.2# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.64.0     0.0.0.0         255.255.248.0   U     0      0        0 eth0
0.0.0.0         192.168.64.1     0.0.0.0         UG    0      0        0 eth0

bash-3.2# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:A0:C9:00:00:02
          inet addr:192.168.70.245  Bcast:192.168.71.255  Mask:255.255.248.0
          inet6 addr: fe80::2a0:c9ff:fe00:2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1044 errors:0 dropped:0 overruns:0 frame:0
          TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:141103 (137.7 KiB)  TX bytes:866 (866.0 b)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.255.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:344 (344.0 b)  TX bytes:344 (344.0 b)

So packet is flowing now.
Commands for reference:
  1. ifconfig
  2. route
  3. arp
  4. ping

Linux Domain Name Lookup Command


For DNS concept,  see the wiki link


 # nslookup google.com
Server:         171.70.168.183
Address:        171.70.168.183#53

Non-authoritative answer:
Name:   google.com
Address: 74.125.239.131
Name:   google.com
Address: 74.125.239.132
Name:   google.com
Address: 74.125.239.135
Name:   google.com
Address: 74.125.239.142
Name:   google.com
Address: 74.125.239.136
Name:   google.com
Address: 74.125.239.129
Name:   google.com
Address: 74.125.239.130
Name:   google.com
Address: 74.125.239.134
Name:   google.com
Address: 74.125.239.128
Name:   google.com
Address: 74.125.239.137
Name:   google.com
Address: 74.125.239.133

See wiki for an high level view.


http://en.wikipedia.org/wiki/Nslookup


; <<>> DiG 9.2.4 <<>> google.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58279
;; flags: qr rd ra; QUERY: 1, ANSWER: 11, AUTHORITY: 4, ADDITIONAL: 4

;; QUESTION SECTION:
;google.com.                    IN      A

;; ANSWER SECTION:
google.com.             172     IN      A       74.125.239.142
google.com.             172     IN      A       74.125.239.137
google.com.             172     IN      A       74.125.239.133
google.com.             172     IN      A       74.125.239.132
google.com.             172     IN      A       74.125.239.130
google.com.             172     IN      A       74.125.239.129
google.com.             172     IN      A       74.125.239.135
google.com.             172     IN      A       74.125.239.131
google.com.             172     IN      A       74.125.239.134
google.com.             172     IN      A       74.125.239.128
google.com.             172     IN      A       74.125.239.136

;; AUTHORITY SECTION:
google.com.             96903   IN      NS      ns2.google.com.
google.com.             96903   IN      NS      ns1.google.com.
google.com.             96903   IN      NS      ns3.google.com.
google.com.             96903   IN      NS      ns4.google.com.

;; ADDITIONAL SECTION:
ns1.google.com.         271309  IN      A       216.239.32.10
ns2.google.com.         239136  IN      A       216.239.34.10
ns3.google.com.         274650  IN      A       216.239.36.10
ns4.google.com.         273632  IN      A       216.239.38.10

;; Query time: 5 msec
;; SERVER: 171.70.168.183#53(171.70.168.183)
;; WHEN: Fri Aug 30 12:56:23 2013
;; MSG SIZE  rcvd: 340

 # /usr/bin/host www.google.com
www.google.com has address 74.125.28.147
www.google.com has address 74.125.28.104
www.google.com has address 74.125.28.106
www.google.com has address 74.125.28.103
www.google.com has address 74.125.28.105
www.google.com has address 74.125.28.99

Here is one good article about those 3 tools.
http://blog.smalleycreative.com/linux/nslookup-is-dead-long-live-dig-and-host/

What happened if meeting the following issues:

bash-3.2# nslookup google.com
;; connection timed out; no servers could be reached 
Check your configure file:
bash-3.2# cat /etc/resolv.conf 
It is empty, so that is why :))
To solve the problem, do following configuration:
bash-3.2# cat /etc/resolv.conf
search comcast.com
nameserver 1.2.3.4
nameserver 4.3.2.1


Monday, October 8, 2012

Linux Networking --- Bridge


When I am doing research on open virtual switch, which is different from Cisco's distributed Nexus 1000 virtual switch,  found its command format is similar to original Linux bridge.

My Linux networking experience will start here.  This is just the log for my own expertise upgrading experience. To start,  I will dive in the following:
1.) Document: http://lxr.linux.no/#linux+v3.6.1/Documentation/networking/bridge.txt
2.) Source Code : http://lxr.linux.no/#linux+v3.6.1/net/bridge/