How to define an IP address in linux?

The command to do all these manipulations at the level of your network card is ifconfig.
This command as root to type, is mainly used:
- Define or change the IP address of an interface,
- Change the subnet mask,
- Enable and disable an interface.

In this tip, we will use the interface “eth0″ which is the first Ethernet interface on your PC. If you have more than one interface, the second will be named “eth1″ and so on.

To set or change the IP address of the interface “eth0″ giving value “192.168.0.1″, then type the following command:
ifconfig eth0 192.168.0.1
To change the mask and attach it to the value “255.255.255.0″, the command is: ifconfig eth0 netmask 255.255.255.0.
Note that:
- These two commands can be concatenated: ip_address netmask ifconfig nom_de_l_interface masque_de_sous_réseau.
- When you define an address for a new interface, if you omit the mask, it will be that of the default value for the class of address. Simply put, know that this default is more than enough for normal use and it is not necessary to specify it.

To enable / disable an interface, the command is: ifconfig eth0 up to activate and ifconfig eth0 down to turn it off.

To check your configuration, you can type ifconfig-a show that you configure all your network cards.

Leave a Comment