York's Blog

Linux Networking Commands

| Comments

A quick note of linux networking commands.

NIC


ifconfig

View IP Address and Hardware / MAC address assign to interface and also MTU size.

Set MTU size. The maximum transmission unit (MTU) of a communications protocol of a layer is the size (in bytes) of the largest protocol data unit that the layer can pass onwards.

ifconfig eth0 mtu XXXX

Set promiscuous mode. Promiscuous mode causes the controller to pass all traffic it receives to the central processing unit (CPU) rather than passing only the frames that the controller is intended to receivem Normally used for packet sniffing.

ifconfig eth0 - promisc

Show all NICs including disabled ones.

ifconfig -a

ifup

Enable a specific interface.

ifdown

Disable a specific interface.

ethtool

View, set speed and duplex for NIC.

iwconfig

ifconfig for wireless.

Routing


arp

View ARP(Address Resolution Protocol) table.

ping

Send ICMP ECHO_REQUEST packet to network hosts.

fping

ping in parallel. Unlike ping, fping is meant to be used in scripts and its output is easy to parse.

traceroute

Shows number of hops taken to reach destination as well as determine packets traveling path.

tcptraceroute

traceroute using TCP packets rather than ICMP Echo Requests and Replies.

mtr

mtr combines the functionality of the traceroute and ping programs in a single network diagnostic tool.

route

Shows and manipulate ip routing table.

route add -net 10.10.10.0/24 gw 192.168.0.1
route del -net 10.10.10.0/24 gw 192.168.0.1
route add default gw 192.168.0.1

Status / Monitoring / Packet


netstat

Display connection info.

netstat -a

Display routing table.

netstat -r

Displaying service name with PID.

netstat -tp

Display promiscuous mode and refresh every 5 seconds.

netstat -ac 5 | grep tcp

tcpdump

Packet analyzer.

iptraf / iptraf-ng

TCP and UDP traffic statistics.

DNS


dig

Query DNS related information like A Record, CNAME, and MX Record. In dnsutils debian package.

Query all.

dig yahoo.com ANY +noall +answer

DNS reverse lookup.

dig -x 72.30.38.140 +short

nslookup

Query DNS related information.

Query all available DNS records.

nslookup -query=any yahoo.com

Debug mode.

nslookup -debug yahoo.com

host

Find name to IP or IP to name in IPv4 or IPv6 and also query DNS records. Use -t option to find out DNS Resource Records like CNAME, NS, MX, and SOA.

hostname

Get hostname of the machine.

whois

Check the internic database for proper hostnames.

Connection


telnet

ftp

ssh

nc

Netcat.

Server / Client.

nc -l 2389
nc localhost 2389
HI, server

wget

curl

lynx

Text web browser.

links

Text web browser.

Others


wall

Broadcast message to all logged in users.

write

Send message to a specific user in the specified tty.

iptables

Firewall.

Configuration Files


/etc/network/interfaces

Network configuration file.

/etc/resolv.conf

DNS configuration.

/etc/hostname

Hostname configuration.

/etc/hosts

Local DNS.

/etc/security/limits.conf

File descriptors and other limits.

System Status


top

htop

dstat

free

df

dmesg

vmstat

who

ps

mpstat

vmstat

Comments

comments powered by Disqus