Disqus for Cyber Fort

Monday, 5 August 2013

Pin It

Widgets

Linux ifconfig : How To Set Ip Address / Configure Interface

Linux ifconfig command stand for interface configuration, it is used in the debugging and configuration of the network interfaces parameters. Ifconfig command can be used to display and set ip address to network interfaces in linux.



Show the network interface status

If you write the command without any options it will give you the status of all the up interfaces,as shown below. You can also find the MAC address binded to that interface in the output.
[root@LinuxServer ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 44:87:FC:A4:C5:DD
inet addr:192.168.1.30 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::4687:fcff:fef4:458d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6053915 errors:0 dropped:11 overruns:0 frame:0
TX packets:757638 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:794654447 (757.8 MiB) TX bytes:2415435778 (2.2 GiB)
Interrupt:17
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:3298 errors:0 dropped:0 overruns:0 frame:0
TX packets:3298 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0

RX bytes:245808 (240.0 KiB) TX bytes:245808 (240.0 KiB)
You can also show a specific interface or all the up and down interfaces as shown below
[root@LinuxServer ~]# ifconfig -a //Will show all up and down interfaces
[root@LinuxServer ~]# ifconfig eth0 //Will show only eth0 status

Enable and disable the interface

You can enable and disable the interface using the up and down options as below
[root@LinuxServer ~]# ifconfig eth0 up //Enable eth0
[root@LinuxServer ~]# ifconfig eth0 down //Disable eth0

Configure the IP address and subnet mask

[root@LinuxServer ~]# ifconfig eth0 192.168.1.30 netmask 255.255.255.0
The above example configure eth0 with ip address 192.168.1.30 with subnet mask 255.255.255.0, you can configure each parameter separately as below
[root@LinuxServer ~]# ifconfig eth0 192.168.1.30
[root@LinuxServer ~]# ifconfig eth0 netmask 255.255.255.0

Enable and disable ARP protocol to specific interface

ARP stands for the address resolution protocol, it is used for resolution of network layer addresses into link layer addresses.
[root@LinuxServer ~]# ifconfig eth0 arp //Enable arp
[root@LinuxServer ~]# ifconfig eth0 -arp //Disable arp

Change the MAC address of interface

In order for this command to work, you should disable the interface and also the hardware vendor support this function. To change the MAC address do the following.
root@LinuxServer ~]# ifconfig eth0 down
root@LinuxServer ~]# ifconfig eth0 22:67:df:1c:11:4f
root@LinuxServer ~]# ifconfig eth0 up
As I mentioned above this command will only work with NICs that supports that

The Promiscuous option

The promisc mode is mostly used in monitoring, this command allow you to receive packets regardless you are the intended recipient.
[root@LinuxServer ~]# ifconfig eth0 promisc //Enable promisc mode
[root@LinuxServer ~]# ifconfig eth0 -promisc //Disable promisc mode

Changing the MTU

MTU stands for Maximum Transmission Unit, it is the size of the largest block of data that can be transmitted as a single unit, the default value is 1500, you can change it as the below example
[root@LinuxServer ~]# ifconfig eth0 mtu 1700



0 comments :