Ubuntu ifconfig static ip

Setup Ubuntu static ip address with ifconfig command. Here is a part of ifconfig information from the manual page:


NAME
ifconfig - configure a network interface
SYNOPSIS
ifconfig [-v] [-a] [-s] [interface]
ifconfig [-v] interface [aftype] options | address ...
DESCRIPTION
Ifconfig is used to configure the kernel-resident network interfaces.
It is used at boot time to set up interfaces as necessary. After that,it
is usually only needed when debugging or when system tuning is
needed.

The ifconfig command is used to manipulate ip address in Ubuntu. We can setup a new ip address for a network card or change ip address and netmask of existing card. From the synopsis above, we can simply use ifconfig command format as:


ifconfig (interface) (ip address)

Here are some ifconfig command examples for you:


Example 01 - Using ifconfig command with no option.






luzar@ubuntu:~$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:0c:29:d2:1d:9b
inet addr:192.168.1.3 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fed2:1d9b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:58 errors:0 dropped:0 overruns:0 frame:0
TX packets:65 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6339 (6.1 KB)
TX bytes:8656 (8.4 KB)
Interrupt:16 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:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B)
TX bytes:0 (0.0 B)
luzar@ubuntu:~$


Example 02 - Using ifconfig command to setup ip address for a second Ethernet card in Ubuntu system.



luzar@ubuntu:~$ ifconfig eth1 192.168.44.128 netmask 255.255.255.0
broadcast 192.168.44.255 up


The ifconfig command above should be in one line.


Example 03 - Using ifconfig command to change ip address for existing Ethernet card in Ubuntu system.



luzar@ubuntu:~$ ifconfig eth0 192.168.1.3




luzar@ubuntu:~$ ifconfig eth0 netmask 255.255.255.0 




Restart network service: