The commands for networking with Kali OS is

ifconfig; route -n; cat /etc/resolv.conf; cat /etc/network/interfaces; cat /etc/hosts

 

Where,

 

  • ifconfig:

Displays various bits of information about the NIC (e.g. IP addresses, subnet, MAC address etc).

Note: ifconfig -a, will display information about ALL NICs

root@kali:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0b:29:9c:c9:b3  
          inet addr:172.108.41.233  Bcast:172.108.41.2355  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:ff9b:c9a3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:292216 errors:0 dropped:0 overruns:0 frame:0
          TX packets:135628 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:431730275 (411.7 MiB)  TX bytes:7398306 (7.0 MiB)
          Interrupt:19 Base address:0x2000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:26 errors:0 dropped:0 overruns:0 frame:0
          TX packets:26 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1648 (1.6 KiB)  TX bytes:1648 (1.6 KiB)

root@kali:~#

You can also alter the state of the NIC by placing it in either 'down' or 'up' state, which disables or enables the NIC

root@kali ~$ ifconfig eth0 down
root@kali ~$ ping -c 1 google.com
ping: unknown host google.com
root@kali ~$ ifconfig eth0 up
root@kali ~$ ping -c 1 google.com
PING google.com (62.252.173.153) 56(84) bytes of data.
64 bytes from m409-mp1-cvx1c.lan.ntl.com (62.252.173.153): icmp_req=1 ttl=128 time=18.0 ms

--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 18.061/18.061/18.061/0.000 ms
root@kali ~$

 

  • route -n

Displays the routing table i.e., gateways information.

root@kali:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.108.41.23     0.0.0.0         UG    0      0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
root@kali:~#

 

  • cat /etc/resolv.conf

Displays the DNS information

root@kali:~# cat /etc/resolv.conf
# Generated by NetworkManager
domain localdomain
search localdomain
nameserver 172.108.41.23
root@kali:~#

 

  • cat /etc/network/interfaces

Displays the network interface configuration

Note: eth0 is set up to use DHCP.

root@kali:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback
root@kali:~#

# The loopback network interface
auto lo
iface lo inet loopback
root@kali:~#

 

  • cat /etc/hosts

Static values for hostname lookups

Note: Editing these values, will NOT change your hostname (for that look into hostname & /etc/hostname).

root@kali:~# cat /etc/hosts
127.0.0.1	localhost
127.0.1.1	kali-offsec

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
root@kali:~#

 

Was this answer helpful? 0 Users Found This Useful (0 Votes)