Monday, 5 March 2012

Useful Linux Commands

# ethtool eth0   -------- Show the ethernet status (replaces mii-diag)
# ethtool -s eth0 speed 100 duplex full # Force 100Mbit Full duplex
# ethtool -s eth0 autoneg off # Disable auto negotiation
# ethtool -p eth1 # Blink the ethernet led

# ip link show  # Display all interfaces on Linux
# ip link set eth0 up  # Bring device up
# ifconfig eth0 up
# ip addr show   # Display all IP addresses on Linux
# ip neigh show    # Similar to arp -a

#  arp -a  # Check the router (or host) ARP entry
# traceroute ctechz.blogspot.in  # Print the route path to destination
# netstat -s   # System-wide statistics for each network protocol
# arping 192.168.16.254  # Ping on ethernet layer

Routing

# route -n  # Linux or use "ip route"
#  netstat -rn # Linux, BSD and UNIX

# route add -net 192.168.20.0 netmask 255.255.255.0 gw 192.168.16.254
#route add -net 192.168.20.0 netmask 255.255.255.0 dev eth0
# route add default gw 192.168.51.254
# route delete -net 192.168.20.0 netmask 255.255.255.0


add -p to make the route persistent.

Configure additional IP address

# ifconfig eth0 192.168.50.254 netmask 255.255.255.0 # first ip
# ifconfig eth0:0 192.168.51.254 netmask 255.255.255.0  
             # Second IP

Changing the MAC Address

# ifconfig eth0 down
# ifconfig eth0 hw ether 00:01:02:03:04:05

Port's In Use

# netstat -an | grep LISTEN 
# lsof -i  # List all Internet connections
# netstat -anp --udp --tcp | grep LISTEN 
# netstat -tup  # List active connections to/from system
# netstat -tupl # List listening ports from system
# netstat -ano  # Windows

IP Forwarding for routing in linux machines

# cat /proc/sys/net/ipv4/ip_forward  # Check IP forward 0=off, 1=on
# echo 1 > /proc/sys/net/ipv4/ip_forward
 or edit /etc/sysctl.conf with:
net.ipv4.ip_forward = 1

 

No comments:

Post a Comment