- List the current network interface configuration:
$ ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:6078 errors:0 dropped:0 overruns:0 frame:0
TX packets:6078 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:634520 (634.5 KB) TX bytes:634520 (634.5 KB)
wlan0 Link encap:EthernetHWaddr 00:1c:bf:87:25:d2
inet addr:192.168.0.82 Bcast:192.168.3.255 Mask:255.255.252.0
inet6addr: fe80::21c:bfff:fe87:25d2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:420917 errors:0 dropped:0 overruns:0 frame:0
TX packets:86820 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:98027420 (98.0 MB) TX bytes:22602672 (22.6 MB)
The leftmost column in the ifconfig output lists the names of network interfaces, and the right-hand columns show the details related to the corresponding network interface.
- To set the IP address for a network interface, use the following command:
# ifconfig wlan0 192.168.0.80
You will need to run the preceding command as root
192.168.0.80 is defined as the address for the wireless device, wlan0
To set the subnet mask along with the IP address, use the following command:
# ifconfig wlan0 192.168.0.80 netmask 255.255.252.0
- Many networks use Dynamic Host Configuration Protocol (DHCP) to assign IP addresses automatically when a computer connects to the network. The dhclient command assigns the IP address when your machine is connected to a network that assigns IP addresses automatically. If addresses are assigned via DHCP, use dhclient instead of manually choosing an address that might conflict with another machine on the network. Many Linux distributions invoke dhclient automatically when they sense a network cable connection
# dhclient eth0