Download presentation
Presentation is loading. Please wait.
1
Linux Networking Commands
2
Commands Reviewed Ifconfig dmesg netstat ping route tcpdump wireshark
traceroute nslookup arp dig
3
ifconfig ifconfig is used to assign an address to a network interface and/or configure network interface parameters. To determine if an interface has been recognized and configured on a system To initially assign an IP address to an interface to bring an interface up or down
4
View All Network Setting
The “ifconfig” command with no arguments will display all the active interfaces details.
5
Display Information of All Network Interfaces
ifconfig command with -a argument will display information of all active or inactive network interfaces on server.
6
ifconfig View Network Settings of Specific Interface
Enable an Network Interface
7
ifconfig Assign a IP Address to Network Interface
~]# ifconfig eth Assign a netmask to Network Interface ~]# ifconfig eth0 netmask Assign a Broadcast to Network Interface ~]# ifconfig eth0 broadcast Assign all in one command ~]# ifconfig eth netmask broadcast Change the MAC address of Network Interface ~]# ifconfig eth0 hw ether AA:BB:CC:DD:EE:FF
8
ifconfig Change MTU for an Network Interface
~]# ifconfig eth0 mtu 1000 Enable and disablePromiscuous Mode ~]# ifconfig eth0 promisc ~]# ifconfig eth0 –promisc Add or remove New Alias to Network Interface ~]# ifconfig eth0: ~]# ifconfig eth0:0 down Verify the newly created alias network interface address ~]# ifconfig eth0:0 eth0:0 Link encap:Ethernet HWaddr 00:01:6C:99:14:68 inet addr: Bcast: Mask: UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:17
9
See if the device has been found - use dmesg
The command 'dmesg', which is used to print kernel messages, is very useful in determining if a piece of hardware has been found, and if so, what the system is referring to it as. Examples: dmesg dmesg | grep -i eth0 dmesg | grep -i usb dmesg | grep -i Memory dmesg | grep -i bluetooth dmesg | grep -i tty dmesg –c clear dmesg logs from boot time to till that time
10
ping Confirm that a remote host is online and responding.
ping is intended for use in network testing, measurement, and management. It is unwise to use ping during normal operations or from automated scripts.
11
Decrease /Increase Ping Time Interval
$ ping -i 5 IP # ping -i 0.1 IP Note: Only super user can specify interval less than 0.2 seconds. Check local interface $ ping 0 $ ping localhost $ ping Send n packets and stop: $ ping -c 5 google.com Display the current version of ping program $ ping -V
12
Ping 5. Flood the network Audible ping: Change Ping Packet Size
# ping -f localhost Audible ping: $ ping -a IP Change Ping Packet Size $ ping -s 100 localhost Specify path for ping to send the packet $ ping Record and print route of how ECHO_REQUEST sent and ECHO_REPLY received $ ping -R
13
Route command Display Existing Routes
if the destination is within the network range – , then the gateway is *, which is By default route command displays the host name in its output. We can request it to display the numerical IP address using -n option as shown below.
14
Adding a Default Gateway List Kernel’s Routing Cache Information
$ route add default gw List Kernel’s Routing Cache Information Reject Routing to a Particular Host or Network route add -host reject
15
Note traceroute Traceroute has lost some of
traceroute attempts tracing by launching UDP probe packets with a small TTL (time to live), then listening for an ICMP "time exceeded" reply from a gateway. host is the destination hostname or the IP number of host to reach. packetsize is the packet size in bytes of the probe datagram. Default is 38 bytes. Note Traceroute has lost some of its effectiveness since most ISP’s disallow it from running on their networks
16
netstat List out all connections List only TCP or UDP connections
$ netstat –a List only TCP or UDP connections $ netstat –at $ netstat –au Disable reverse dns lookup for faster output: By default, the netstat command tries to find out the hostname of each ip address in the connection by doing a reverse dns lookup. This slows down the output. $ netstat -ant
17
netstat Print statistic List out only listening connections
$ netstat -s List out only listening connections $ netstat –tnl Get process name/pid and user id $ sudo netstat –nlpt Use the e option along with the p option to get the username too. $ sudo netstat -ltpe
18
netstat -nr [root@localhost root]# netstat -nr Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface U eth0 U eth1 U lo UG eth1
19
nslookup Query Internet domain name servers.
$ nslookup redhat.com $ nslookup -query=mx redhat.com nslookup -type=ns redhat.com Query the SOA Record using -query=soa provides the authoritative information about the domain, the address of the domain admin, the domain serial number, etc… $ nslookup -type=soa redhat.com View available DNS records using -query=any $ nslookup -type=any google.com Reverse DNS lookup $ nslookup redhat.com ns1.redhat.com
20
arp -a [root@localhost root]# arp -a
gatewayout.tcp-ip.ca ( ) at 00:04:5A:DB:A1:C5 [ether] on eth1 basement.tcp-ip.ca ( ) at 00:10:E0:04:61:84 [ether] on eth0 just_a_node.tcp-ip.ca ( ) at 00:09:B7:13:AA:13 [ether] on eth1
21
dig - supercharged nslookup
root]# dig cs.senecac.on.ca ; <<>> DiG <<>> cs.senecac.on.ca ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10483 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 6, ADDITIONAL: 4 ;; QUESTION SECTION: ;cs.senecac.on.ca IN A ;; ANSWER SECTION: cs.senecac.on.ca IN A
22
dig - better than nslookup
;; AUTHORITY SECTION: senecac.on.ca IN NS ns.onet.on.ca. senecac.on.ca IN NS ns2.senecac.on.ca. senecac.on.ca IN NS hades.senecac.on.ca. senecac.on.ca IN NS ittads.senecac.on.ca. senecac.on.ca IN NS pulsar.senecac.on.ca. senecac.on.ca IN NS nsprime.senecac.on.ca. ;; ADDITIONAL SECTION: ns2.senecac.on.ca IN A hades.senecac.on.ca IN A ittads.senecac.on.ca IN A pulsar.senecac.on.ca IN A ;; Query time: 2202 msec ;; SERVER: #53( ) ;; WHEN: Sun Sep 29 16:38: ;; MSG SIZE rcvd: 238
23
tcpdump tcpdump is a most powerful and widely used command-line packets sniffer or package analyzer tool which is used to capture or filter TCP/IP packets that received or transferred over a network on a specific interface. # yum install tcpdump $ apt-get install tcpdump Capture Packets from Specific Interface # tcpdump -i eth0 Capture Only N Number of Packets # tcpdump -c 5 -i eth0
24
Display Available Interfaces Capture and Save Packets in a File
# tcpdump –D Capture and Save Packets in a File # tcpdump -w 0001.pcap -i eth0 Read Captured Packets File # tcpdump -r 0001.pcap Capture only TCP packets # tcpdump -i eth0 tcp Capture Packet from Specific Port # tcpdump -i eth0 port 22 Capture Packets from destination /src IP # tcpdump -i eth0 dst # tcpdump -i eth0 src
25
Wireshark Wireshark is a open source and freely available network analyzer tool which is shipped with most of the Linux distributions now a days.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.