← Blog

Administración de Red en Linux

Comandos de red en Linux: ifconfig, ip, netstat, configuración de interfaces y resolución DNS.

Network details

/sbin/ifconfig -a
cat /etc/network/interfaces
cat /etc/sysconfig/network
ip a 
ip addr

cat /etc/resolv.conf
cat /etc/sysconfig/network
cat /etc/networks
iptables -L
hostname
dnsdomainname

Existing connections

lsof -i
lsof -i :80
grep 80 /etc/services
netstat -antup
netstat -antpx
netstat -tulpn
chkconfig --list
chkconfig --list | grep 3:on
last
w

## Cached IPs 
arp -e
route
/sbin/route -nee

### TCPDUMP
tcpdump tcp dst 192.168.1.7 80 and tcp dst 10.5.5.252 21

Networking

  • Manage network interfaces
vi /etc/network/interfaces
  • Set static ip
vi /etc/network/interfaces

# The primary network interface
auto eth0
iface eth0 inet static
address 10.0.0.100
netmask 255.255.255.0
gateway 10.0.0.1

Restart networking with $ service networking restart

  • Networking:

    ping google.com
    # test two-way connectivity
    
    ping -c 4 google.com
    # sends 4 packets
    
    ifconfig
    # lists network interfaces configured
    
    ip a
    # modern alternative to ifconfig
    
    ip -s link
    # provides stats
    
    ip help
    # for more options
    
    ip route
    # view routing info
    
    route
    # similar info as 'ip route'
    
    nslookup google.com
    # dns lookup
    
    dig google.com
    # dns lookup with more info
    
    dig -x 8.8.8.8
    # reverse lookup
    
    netstat -at
    # view open TCP connections
    
    netstat -lt
    # listening TCP ports