a) Dynamic IP Address - by using DHCP (Dynamic Host Configuration Protocol) server
b) Static IP Address - by Setting a fix IP address for NIC.
Configuring DHCP Address for Network Interface Card (NIC)
Just edit the /etc/network/interfaces file to configure dynamic IP address for the network card.
susanta@admin:~$ sudo gedit /etc/network/interfaces
# auto lo# iface lo inet loopback
auto eth0
iface eth0 inet dhcp
Here the IP address of the Network card will be collected from local DHCP server.
Now execute the following command to set IP address from DHCP server.
susanta@admin:~$ sudo /etc/init.d/networking restart
* Reconfiguring network interfaces... Internet Systems Consortium DHCP Client V3.1.3
Copyright 2004-2009 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/eth0/00:16:76:1e:6a:60
Sending on LPF/eth0/00:16:76:1e:6a:60
Sending on Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 8
................................
................................
Configuring Static IP Address for Network Interface Card (NIC)
Same way edit the /etc/network/interfaces file to configure static IP address for the network card.
susanta@admin:~$ sudo gedit /etc/network/interfaces
# auto lo
# iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.2
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
# iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.2
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
Now restart the networking script file to set IP address for the Network Interface Card.
susanta@admin:~$ sudo /etc/init.d/networking restart
To check whether the new IP address is set for the network interface card, execute the following command,
susanta@admin:~$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:16:76:1e:6a:60
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 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:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:21 Base address:0xde00
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:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:480 (480.0 B) TX bytes:480 (480.0 B)
ppp0 Link encap:Point-to-Point Protocol
inet addr:10.1.77.54 P-t-P:2.2.2.2 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:1585 errors:0 dropped:0 overruns:0 frame:0
TX packets:1744 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:553960 (553.9 KB) TX bytes:792791 (792.7 KB)
Note: We can also set second IP address or virtual IP address for same network interface
susanta@admin:~$ sudo gedit /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.1.2
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
auto eth0:1
iface eth0:1 inet static
address 192.168.1.3
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
iface eth0 inet static
address 192.168.1.2
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
auto eth0:1
iface eth0:1 inet static
address 192.168.1.3
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
Now execute the following command to check, whether it is working properly,
susanta@admin:~$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:16:76:1e:6a:60
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 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:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:21 Base address:0xde00
eth0:1 Link encap:Ethernet HWaddr 00:16:76:1e:6a:60
inet addr:192.168.1.3 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
Interrupt:21 Base address:0xde00
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:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:480 (480.0 B) TX bytes:480 (480.0 B)
eth0 Link encap:Ethernet HWaddr 00:16:76:1e:6a:60
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 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:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:21 Base address:0xde00
eth0:1 Link encap:Ethernet HWaddr 00:16:76:1e:6a:60
inet addr:192.168.1.3 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
Interrupt:21 Base address:0xde00
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:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:480 (480.0 B) TX bytes:480 (480.0 B)
No comments:
Post a Comment