Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
55 views

Configuring NIC in Linux

1. The document discusses configuring network interfaces and IP addresses in Linux. It describes how to view the IP address of a Linux server using ifconfig, manually assign an IP address to an interface, and configure IP addresses to persist after reboots by editing files in /etc/sysconfig/network-scripts. 2. It also covers using DHCP to configure an interface, creating multiple IP addresses on a single network interface using IP aliases, and how DHCP can affect the DNS servers configured on a Linux system. 3. Configuring static IP addresses or using DHCP, editing interface configuration files, and commands like ifconfig, ifup, and ifdown allow Linux servers to have network interfaces and IP addresses configured

Uploaded by

Phillip Peters
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

Configuring NIC in Linux

1. The document discusses configuring network interfaces and IP addresses in Linux. It describes how to view the IP address of a Linux server using ifconfig, manually assign an IP address to an interface, and configure IP addresses to persist after reboots by editing files in /etc/sysconfig/network-scripts. 2. It also covers using DHCP to configure an interface, creating multiple IP addresses on a single network interface using IP aliases, and how DHCP can affect the DNS servers configured on a Linux system. 3. Configuring static IP addresses or using DHCP, editing interface configuration files, and commands like ifconfig, ifup, and ifdown allow Linux servers to have network interfaces and IP addresses configured

Uploaded by

Phillip Peters
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1.

1 Configuring Network Card in Linux


As a beginner hacker it is critical to know the phases required to configure an
Internet Protocol addresses on your Server’s Network Interface Card adapter. Linux
users may also need to be conversant of the skill to add an additional NIC interface
to your server. Network Interface setup is a very important skill for all Linux experts.
This book section shows the common processes followed in setting networking on
your Server.

1.2 What is your IP Address


It is critical for Linux people to know the IP Address of the Server, the command
ifconfig -a below displays all the information about a network interface.

[ppeters@rad-srv ~]$ ifconfig -a

ensp0 Link encap:Ethernet HWaddr 00:08:g7:30:34:y8


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:100
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:11 Base address:0x1820

lo Link encap:Local Loopback


inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:787 errors:0 dropped:0 overruns:0 frame:0
TX packets:787 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:82644 (80.7 Kb) TX bytes:82644 (80.7 Kb)

wlan0 Link encap:Ethernet HWaddr 00:26:45:18:4D:G5


inet addr:172.16.2.200 Bcast:192.168.2.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:47379 errors:0 dropped:0 overruns:0 frame:0
TX packets:107900 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:4676853 (4.4 Mb) TX bytes:43209032 (41.2 Mb)
Interrupt:11 Memory:c887a000-c887b000

wlan0:0 Link encap:Ethernet HWaddr 00:26:45:18:4D:G5


inet addr:172.16.5.79 Bcast:172.16.5.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:11 Memory:c887a000-c887b000
[root@bigboy tmp]#

In this situation there is no IP address on the ensp0 network gateway, since the
VirtualBox is its only NIC by way of a wireless access card wlan0. Adapter wlan0 has
a 172.16.2.200 IP address and a 255.255.255.0 subnet mask you will notice that this
control provides the best interrupt data or the PCI bus ID that is used by the device.
You that notice your NIC card is not operating on a very rare occasion because it has
an interrupt and a connection to a storage with a network. To get a database of all
interrupt IRQs the system uses, you can access the /proc/interrupts directory
contents. The following example demonstrates that no problems arise with each IRQ
from 0 to 15 with only one application. ensp0 and ensp1 interface cards, respectively,
are used for interrupts of 10 and 5.:

[ppeters@rad-srv ~]$ cat /proc/interrupts


CPU0
0: 2707402473 XT-PIC timer
1: 67 XT-PIC i8042
2: 0 XT-PIC cascade
5: 411342 XT-PIC ensp1
8: 1 XT-PIC rtc
10: 1898752 XT-PIC ensp0
11: 0 XT-PIC uhci_hcd
12: 58 XT-PIC i8042
14: 5075806 XT-PIC ide0
15: 506 XT-PIC ide1
NMI: 0
ERR: 43
[ppeters@rad-srv ~]$

If there are problems, the Linux documentation for the offending machine may be
needed to try and find ways to use a different interrupt or memory I / O position.
1.3 Modifying IP Addresses in Linux
The ifconfig statement above showed us that ensp0 interface has no IP address and
we can manually assign this ensp0 interface an IP address using the ifconfig
command as shown in the statement below.

[ppeters@rad-srv ~]$ ifconfig ensp0 192.168.0.1 netmask 255.255.255.0 up

At the end of the instruction, the "up" switches on the network interface You will
have to apply this instruction to the /etc/rc.local text file that is running at the start
of every restart to make it permanent every time you boot up.
In the /etc/sysconfig/network-scripts tab, Centos Linux often makes life easier with
interface configuration setup files Configuration network interface ensp0 has an
ifcfg-ensp0 file and ifcfg-eth1 is used by eth1, and so on. You could paste your IP
address in these files and which are then used to setup your NICs automatically when
the Linux boots. Regarding two Linux network interface instances, see Figure 3-1.
Firstly, the initial network interface has a set Internet address and secondly, an IP
address assignment utilizing DHCP is available.

Figure 3-1 - File formats for network-scripts

[ppeters@rad-srv ~]$ cd /etc/sysconfig/network-scripts


[ppeters@rad-srv network-scripts]# cat ifcfg-ensp0

#
# File: ifcfg-ensp0
#
DEVICE=ensp0
IPADDR=172.16.2.200
NETMASK=255.255.255.0
BOOTPROTO=static
ONBOOT=yes
#
# The following settings are optional
#
BROADCAST=172.16.2.255
NETWORK=172.16.2.0

[ppeters@rad-srv network-scripts]#
Getting the IP Address Using DHCP

[root@bigboy tmp]# cd /etc/sysconfig/network-scripts


[root@bigboy network-scripts]# cat ifcfg-ensp0

#
# File: ifcfg-ensp0
#
DEVICE=ensp0
BOOTPROTO=dhcp
ONBOOT=yes

[root@bigboy network-scripts]#

As you can see ensp0 will be activated on booting, because the parameter ONBOOT
has the value yes and not no. You can read more about netmasks and DHCP in
Chapter 2, "Introduction to Networking", that acts as an introduction to networking.
The default RedHat/Fedora installation will include the broadcast and network
options in the network-scripts file. These are optional.
After you change the values in the configuration files for the NIC you have to
deactivate and activate it for the modifications to take effect. The ifdown and ifup
commands can be used to do this:

[root@bigboy network-scripts]# ifdown ensp0


[root@bigboy network-scripts]# ifup ensp0

Your server will have to have a default gateway for it to be able to communicate with
the Internet. This will be covered later in the chapter.
2 How DHCP Affects the DNS Server You Use
Your DHCP server not only supplies the IP address your Linux box should use, but
also the desired DNS servers. When using DHCP for an interface, make sure your
/etc/resolv.conf file has the servers configuration lines commented out to prevent
any conflicts.
3 Multiple IP Addresses on a Single NIC

In the previous section "Determining Your IP Address" you may have noticed that
there were two wireless interfaces: wlan0 and wlan0:0. Interface wlan0:0 is actually
a child interface wlan0, a virtual subinterface also known as an IP alias. IP aliasing is
one of the most common ways of creating multiple IP addresses associated with a
single NIC. Aliases have the name format parent-interface-name:X, where X is the
sub-interface number of your choice.
The process for creating an IP alias is very similar to the steps outlined for the real
interface in the previous section, "Changing Your IP Address":

 First ensure the parent real interface exists


 Verify that no other IP aliases with the same name exists with the name you
plan to use. In this we want to create interface wlan0:0.
 Create the virtual interface with the ifconfig command

[root@bigboy tmp]# ifconfig wlan0:0 192.168.1.99 netmask 255.255.255.0 up

 You should also create a /etc/sysconfig/network-scripts/ifcfg-wlan0:0 file so


that the aliases will all be managed automatically with the ifup and ifdown
commands. Here is a sample configuration:

DEVICE=wlan0:0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.99
NETMASK=255.255.255.0

The commands to activate and deactivate the alias interface would therefore be:

[root@bigboy tmp]# ifup wlan0:0


[root@bigboy tmp]# ifdown wlan0:0

Note: Shutting down the main interface also shuts down all its aliases too. Aliases
can be shutdown independently of other interfaces.
After completing these four simple steps you should be able to ping the new IP alias
from other servers on your network.

You might also like