Wednesday 2 November 2011

Network Configurations in Linux

Assigning a static IP address --- temporarily

Syntax:--

[root@server ~]# ifconfig <devicename> <IP address>

Example:-- To Assign the static IP address as 192.168.10.121

[root@server ~]# ifconfig eth0 192.168.10.121

To check the IP assigned

[root@server ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:08:02:F7:33:6A
          inet addr:192.168.10.121  Bcast:192.168.10.255  Mask:255.255.255.0
          inet6 addr: fe80::208:2ff:fef7:336a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:773 errors:0 dropped:0 overruns:0 frame:0
          TX packets:137 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:77098 (75.2 KiB)  TX bytes:23592 (23.0 KiB)
          Interrupt:177

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:1670 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1670 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:3349244 (3.1 MiB)  TX bytes:3349244 (3.1 MiB)

Set Permanent IP address

Do the following Steps:

1. Go to the following Path

    [root@server ~]# cd /etc/sysconfig/network-scripts/

2. After that edit the following file

   [root@server network-scripts]# vi ifcfg-eth0
  
# Broadcom Corporation NetXtreme BCM5702X Gigabit Ethernet
DEVICE=eth0
HWADDR=00:08:02:f7:33:6a
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=192.168.10.121
GATEWAY=192.168.10.254
TYPE=Ethernet
~
~
:wq!

3. After this restart the network service to activate the new IP address.

To see the LAN card i.e NIC card Parameters


[root@server ~]# ethtool eth0
Settings for eth0:
        Supported ports: [ MII ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Half 1000baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Half 1000baseT/Full
        Advertised auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: g
        Wake-on: d
        Current message level: 0x000000ff (255)
        Link detected: yes

To enable IP address

[root@server ~]# ifup eth0

To disable IP address

[root@server ~]# ifdown eth0


This is a file where IP address are stored.

[root@server ~]# cd /etc/sysconfig/network-scripts/
[root@server network-scripts]# cat ifcfg-eth0
# Broadcom Corporation NetXtreme BCM5702X Gigabit Ethernet
DEVICE=eth0
HWADDR=00:08:02:f7:33:6a
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=192.168.10.121
GATEWAY=192.168.10.254
TYPE=Ethernet

0 comments:

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Affiliate Network Reviews