ifconfig can be used at the command line to configure (or re-configure) a network interface. This is often unnecessary, since this configuration is typically handled by a script when you boot the system. If you'd like to do so manually, you will need superuser privileges, so we'll use sudo again when running these commands.

To assign a static IP address to an interface, specify the interface name and the IP address. For example, to assign the IP address 69.72.169.1 to the interface wlan0, use the command:
sudo ifconfig wlan0 69.72.169.1
To assign a network mask to an interface, use the keyword netmask and the netmask address. For instance, to configure the interface eth1 to use a network mask of 255.255.255.0, the command would be:
sudo ifconfig eth1 netmask 255.255.255.0
To assign a broadcast address to an interface, use the keyword broadcast and the broadcast address. For instance, to configure the interface wlan1 to use a broadcast address of 172.16.25.98, the command would be:
sudo ifconfig wlan1 broadcast 172.16.25.98
These configurations can combined in a single command. For instance, to configure interface eth0 to use the static IP address 192.168.2.5, the network mask 255.255.255.0, and the broadcast address 192.168.2.7, the command would be:
sudo ifconfig eth0 192.168.2.5 netmask 255.255.255.0 broadcast 192.168.2.7
These are the most commonly-used configuration options for ifconfig. A complete list is provided below.

What About DHCP?

ifconfig can only assign a static IP address to a network interface. If you want to assign a dynamic IP address using DHCP, you should use the dhclient command.

Command Syntax

ifconfig [-v] [-a] [-s] [interface]
ifconfig [-v] interface [aftype] options | address ...


Entradas populares de este blog