Configure Static IP Address on Linux

It is possible to configure a Linux network interface in multiple ways.

This is the one that might be simpler for beginners.

sudo ifconfig eth0 netmask;
sudo route add default gw eth0;

ifconfig is an application that allows to configure a network interface.

In the above example sudo is the command that allows us to elevate the user privileges to configure the network interface.

eth0 is the available interface, the list of available interfaces can be listed using the command ifconfig. is an example of a IP address it can be what you require to configure your network.

netmask identifies the subnet mask for the network that you are configuring. If you not sure what should be check the configuration settings of your router.

the second configuration line is the configuration of the default gateway. To achieve efficiency in getting out of the local network it is required to provide that information to the computer.

The gateway setting is the exit point of the local network to other networks. Route add is the command that it is used to add the route.

Default identifies that this is a default route. If no other route is inserted in the routing table the computer will use this route to speak with the remaining networks.

The address is the ip address of the gateway normally the address of the router in a local network.

The eth0 is the local interface that will be used to reach the gateway.

Comandos Simples de um Switch

banner motd 

Configura a mensagem do dia (message of the day)

configure terminal

entra no modo de configuração de terminal

copy running-config to startup-config

Copia a configuração actual para a configuração de arranque do router.


entra no modo privilegiado

enable secret password

apaga a configuração de arranque

erase startup-configuration

coloca-nos no interface indicado

interface interface

define qual o endereço de ip do interface

ip address address mask

Define qual o gateway

ip default-gateway address

Coloca-nos dentro da consola 0

line console 0

coloca-nos dentro das consolas virtuais 0 a 4

line vty 0 4

activa o pedido de identificação dos utilizadores que acedem ao equipamento via vty ou consola.


define a password dos utilizadores da consola. Quando feito dentro da consola.

password password

pinga um determinado ip

ping ip address

recarrega o IOS


mostra os vizinhos que o CDP aprendeu

show cdp neighbours

Mostra todos os interfaces do equipamento

show interfaces

Mostra o modo em que um determinado interface está.

show port-security interface interface-if {address}

mostra a configuração que está a correr

show running-configuration

desliga e activa por exemplo um interface

shutdown / no shutdown

coloca em modo de acesso um interface

switch-port mode access

activa o modo de segurança de um interface

switch-port port-security

activa o modo de segurança de um interface pelo mac-address

switch-port port-security mac-address mac-address

define qual o numero máximo de mac-address que podem ser ligado no interface

switch-port port-security maximum value