Winter Bootcamp in ML and IoT in Jaipur
 Course content (For Bootcamp & Winter Training):- Machine Learning (ML) || Internet of Things (IoT) || Register for winter bootcamp
0 like 0 dislike
in Tutorial & Interview questions by (3.1k points)

1 Answer

0 like 0 dislike
by (3.1k points)
selected by
 
Best answer

This document covers TCP/IP networking, network administration and system configuration basics. Linux can support multiple network devices. The device names are numbered and begin at zero and count upwards. For example, a computer with two NICs will have two devices labeled eth0 and eth1. 

Local DNS resolution 

File: /etc/hosts contains a list of hosts that are to be resolved locally(not by DNS)

 Sample contents of the file: 

127.0.0.1 your-node-name.your-domain.com localhost.localdomain localhost XXX.XXX.XXX.XXX node-name 

The file format for the hosts file is specified by RFC 952

 Configure DNS servers for domain name resolution 

File: /etc/resolv.conf contains a list of DNS servers for domain name resolution 
Sample contents of the file:
nameserver 8.8.8.8 # IP address of the primary name server 
nameserver 8.8.4.4 # IP address of the secondary name server

In case internal DNS server you can validate if this server resolve DNS names properly using dig command: 

$ dig google.com @your.dns.server.com +short

See and manipulate routes 

Manipulate the IP routing table using route 
Display routing table
$ route # Displays list or routes and also resolves host names 
$ route -n # Displays list of routes without resolving host names for faster results

Add/Delete route 

Option                                             Description 

add or del                    Add or delete a route

-host x.x.x.x               Add route to a single host identified by the IP address 

-net x.x.x.x                Add route to a network identified by the network address 

gw x.x.x.x                 Specify the network gateway

 netmask x.x.x.x      Specify the network netmask 

default                      Add a default route 

Examples: 

  • add route to a host $ route  add -host x.x.x.x eth1 
  • add route to a network $ route add -net 2.2.2.0 netmask 255.255.255.0 eth0 
  • Alternatively, you could also use cidr format to add a route to network route add -net 2.2.2.0/24 eth0 
  • add default gateway $ route add default gw 2.2.2.1 eth0 
  • delete a route $ route del -net 2.2.2.0/24

Manipulate the IP routing table using ip 

Display routing table 

$ ip route show # List routing table

Add/Delete route 

Option                                                                Description 

add or del or change or append or replace        Change a route 

show or flush                                               the command displays the contents of the routing tables or remove it 

restore                                     restore routing table information from stdin 

get                                           this command gets a single route to a destination and prints its contents exactly as the kernel sees it

Examples:

  • Set default gateway to 1.2.3.254 $ ip route add default via 1.2.3.254
  •  Adds a default route (for all addresses) via the local gateway 192.168.1.1 that can be reached on device eth0 

$ ip route add default via 192.168.1.1 dev eth0

Configure a hostname for some other system on your network 

You can configure your Linux (or macOS) system in order to tie in an identifier to some other system's IP address in your network. You can configure it:
  • Systemwide. You should modify the /etc/hosts file. You just have to add to that file a new line containing: 
    • the remote system's IP address , 
    • one or more blank spaces, and 
    • the identifier . 
  • For a single user. You should modify the ~/.hosts file --- you-d have to create it. It is not as simple as for systemwide. Here you can see an explanation.

For instance, you could add this line using the cat Unix tool. Suppose that you want to make a ping to a PC in yout local network whose IP address is 192.168.1.44 and you want to refer to that IP address just by remote_pc. Then you must write on your shell:

$ sudo cat 192.168.1.44 remote_pc  

Then you can make that ping just by: 

$ ping remote_pc 

Interface details 

Ifconfig 
List all the interfaces available on the machine
$ ifconfig -a

List the details of a specific interface 

Syntax: $ ifconfig 

Example:

$ ifconfig eth0 

eth0         Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:xx 

 inet addr:x.x.x.x Bcast:x.x.x.x Mask:x.x.x.x 

 inet6 addr: xxxx::xxx:xxxx:xxxx:xxxx/64 Scope:Link 

 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 

 RX packets:4426618 errors:0 dropped:1124 overruns:0 frame:0 

 TX packets:189171 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:382611580 (382.6 MB) TX bytes:36923665 (36.9 MB) Interrupt:16 Memory:fb5e0000-fb600000 

Winter 10 Days bootcamp classes(7 HRS Daily) will start from 5 & 20 December 2019 in:
1) Internet of things(IoT) Using RASPBERRY-PI
2) Machine Learning (ML)

70% OFF| Fee-INR 3,000/-

Limited seats!! Hurry up!!

[[ CALL - 07976731765 ]]

Some Study Resources are compiled from original Stack Overflow Documentation, the content is developed by the different experts at Stack Overflow. Study resources are released under Creative Commons BY-SA. Images may be copyright of their respective owners. This website is for self-learning and not affiliated with Stack Overflow. All trademarks and registered trademarks are the property of their respective company owners. Please send feedback and corrections to chandwaglobal@gmail.com.

Related questions

...