LAN – Local Area Network
NIC – Network Interface Card
MAC – Media Access Control [00:21:03:A1:15:C6]
[00:21:03 – vendor ID, A1:15:C6 – Serial Number]
Ethernet Adapter – eth0 (LAN 1), eth1 (LAN 2)
ARP – Address Resolution Protocol. [IP to MAC]
Ping – Packet Internet Gopher.
init.d – d – Demon (service)
1. [#$] dmesg – Display Kernel Log message.
2. [#$] dmesg | grep eth0 – Search eth0 is connected or not.
3. [#$] dmesg | grep * – Display all Ethernet interface.
4. [#$] ifconfig – Display the interface properties.
5. [#$] ifconfig eth0 – Display the interface properties of eth0 (1st LAN).
6. [#$] ifconfig –a – [a-all]. Display the interface properties.
7. [#$] system-config-network-cmd – Display LAN information.
8. [#$] mii-tool – Check cable of all interface is connected or not. It has some output:
– Link OK
– Auto negation failed, Link Ok
– No MII Transceiver present
– No link.
9. [#$] mii-tool eth0 – Display the cable is connected or not in eth0 interface.
10. [#$] mii-tool -r – Reset all interface (disable then enable).
11. [#$] mii-tool -r eth0 – Reset eth0 interface (disable then enable).
12. [#$] route –n – Display the Gateway.
Change host Name
13. [#] hostname sum – Change hostname to sum temporary. After restart the
machine the hostname (sum) will not exists.
14. Permanently set host name (this will effect after restart the server)
[#] vi /etc/sysconfig/network
Networking = yes
Hostname = sum
!
15. Input IP and host name in host file. Host file is working locally and it work before DNS. We can ping a machine by host in replace of IP. In that case the host name should be written against IP address in host file.
[#] vi /etc/hosts
127.0.0.1 Localhost.localdomain Localhost à This create during installation
192.168.100.1 sum.com ns1 – Domain – sum.com Host name – ns1
192.168.100.1 ns1.sum.com.bd ns1 – FQDN -Full Qualified Domain Name
(host name. Domain name)
192.168.1.1 Linux1 Mahmud – 2 host name and not case sensitive.
!
[#] ping 192.168.1.2
or
[#] ping Linux1
or
[#] ping Mahmud
Set IP address
Static IP – Put IP manually
Dynamic IP – Pull an IP from DHCP server.
[*] Use Dynamic IP configuration (BOOTP/DHCP) – [* - space bar]
IP Address: 192.168.1.2
Net Mask: 255.255.255.0
Default Gateway (IP): 192.168.1.254
Primary Name Server (DNS): 192.168.1.1
Set IP in LAN card
16. Debina [ vi /etc/network/interface ]
auto eth0
iface eth0 inet static
address 221.120.96.254
netmask 255.255.255.224
network 221.120.96.224
broadcast 221.120.96.255
gateway 221.120.96.225
# For Office AP
auto eth0:0
iface eth0:0inet static
address 172.16.119.1
netmask 255.255.255.224
RedHat
[#$] netconfig – By default set IP in eth0.
[#$] netconfig –d eth1 – Set IP in eth1.
[#$] netconfig - -device eth1 – Set IP in eth1.
[#$] system-config-network – Set IP in eth0 or eth1.
[#$] setup – Network Configuration, Set IP address in eth0 or eth1
[#$] vi /etc/sysconfig/network-scripts/ifcfg-eth0
Device = eth0
ONBoot = yes
BOOT PROTO = static
IPADDRESS = 192.168.1.2
NETMASK = 255.255.255.0
GATEWAY = 192.168.1.254
DNS = 192.168.1.1
If ifcfg-eth0 file is not in network-scripts directory then-
[#] cd /etc/sysconfig/network-scripts
[#] ls – see the file under network-scripts directory.
[#] cp ifcfg-lo ifcfg-eth0 – Create a file named ifcfg-eth0 from lo (loop back)
[#] vi /eht0
17. After set the IP should be restart the service network
[#$] service network restart
[#$] /etc/init.d/network restart
18. IP Aliasing (set more than one IP in a single LAN card)
Temporary (After rebooting the machine the IP will release)
ifconfig eth1 192.168.10.1
ifconfig eth1:0 192.168.10.1 – By default get subnet mask of that IP (2nd IP in a NIC)
ifconfig eth1:1 192.168.10.2 netmask 255.255.255.0 – Give the subnet mask. (3rd IP)
Permanent
[#] vi /etc/rc.local
ifconfig eth1:0 192.168.10.1 netmask 255.255.255.0 – 2nd IP
ifconfig eth1:1 192.168.20.2 netmask 255.255.255.0 – 3rd IP
!
[#] service network restart – After restart the Network service the extra IP will release.
[#] /etc/rc.local – After this command the IP will add in LAN card.
ICMP REQUEST
19. Temporary block replay of ping request (this will deactivate after reboot machine)
[#] cat /proc/sys/net/ipv4/icmp_echo_ignore_all – Display ICMP request is
Blocked or not [0-not block replay of ping request, 1or other is value – block]
[#] echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all – Write 1 to the file for
block the replay of ping request.
20. Permanently block replay of ping request
[#] vi /etc/re.local – this file will execute when PC getting start)
touch à after the touch write the line.
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
!
[#] /etc/rc.local – Run the rc.local file without reboot the machine.
21. Linux and Windows Ping properties
[#$] ping 192.168.1.1 – [Linux] Continuous Ping request
[#$] ping 192.168.1.1 – [Windows] 4 ping request.
[#$] ping 192.168.1.1 –t or /t – [Windows] Continuous Ping request.
[#$] Ctrl + C – [Linux, Windows] Quit form ping request.
[#$] ping 192.168.1.1 –c 10 – [Linux] 10 packet send
[#$] ping 192.168.1.1 –n 10 – [Windows] 10 packet send
[#$] ping 192.168.1.1 –i 5 – [Linux] Send packet after each 5 second.
[#$] ping 192.168.1.1 –s 128 – [Linux] Packet Size change to 128 byte (default 64)
[#$] ping 192.168.1.1 –l 128 – [Win] Packet Size change to 128 byte (default 32)
[Linux by default TTL - 64] [Windows by default TTL - 128]
23. Display the hop to reach the destination and packet loss of each hop.
[#$] traceroute 4.2.2.2 (linux)
mtr 4.2.2.2 (linux)
tracert 4.2.2.2 (win)
pathping 4.2.2.2 (win)
ARP – Address Resolution Protocol. [IP to MAC]
22. [#] arp – a – [a-all]. If the machine has IP 192.168.1.2 then it takes MAC of all IP
holder machine of 192.168.3.0 block.
23. [#] arp 122.247.47.11 – Get the MAC of the IP and check the physical link.
24. [#] arp –i eth1 – [i-interface]. Take MAC of pc’s that are connected by eth1.
25. [#] arp –i eth1 -nv – [i-interface, n- number, v- verbose]. Take MAC of pc’s that
are connected by eth1 and show the number of pc connected by eth1.
MAC Clone
26. Temporary (after reboot the machine the new cloned MAC flashed)
[#] ifconfig eth0 down – Down the eth0 interface
or
[#] ifdown eht0
[#] ifconfig eth0 hw ether 00:21:03:A1:15:C6 – Old MAC
[#] ifconfig eth0 up – Up the eth0 interface
or
[#] ifup eht0
27. Permanently Change the MAC
[#] vi /etc/rc.local
ifdown eht0
ifconfig eth0 hw ether 00:21:03:A1:15:C6 à Old MAC
ifconfig eth0 up – Up the eth0 interface
: x!