How to configure IP address in Linux
Run setup command form root user
#setup
this will launch a new window select network configuration
now a new window will show you all available LAN card select your LAN card ( if you don’t see any LAN card here mean you don’t have install driver)
assign IP in this box and click ok
click on ok, quit and again quit to come back on root prompt.
Alternately you can use system-config-network command directly to invoke this setup window
#system-config-network
whatever change you made in network configuration will not take place till you restart the LAN card
#service network restart
ifconfig
The ifconfig command will display the configuration of all active Ethernet card. Without specifying any parameter this command will show all active Ethernet card. if you want to see the configuration of any specific Ethernet card then use the name of that card as the command line arguments. for example to show the IP configuration on loop back Interface execute this command
#ifconfig lo
ifup/ifdown
Each installed network adapter has a corresponding ifcfg-* file in /etc/sysconfig/network-scripts. You can activate or deactivate that adapter with the ifup and ifdown commands. Either of the following commands will activate the eth0 network adapter:
#ifup ifcfg-eth0 #ifup eth0
netstat
The netstat program provides real-time information on the status of your network connections, as well as network statistics and the routing table. The netstat command has several options you can use to bring up different sorts of information about your network.
arp
The Address Resolution Protocol associates the hardware address of a network adapter with an IP address. The arp command (in the /sbin directory) displays a table of hardware and IP addresses on the local computer. With arp, you can detect problems such as duplicate addresses on the network, or you can manually add arp entries as required.
mii-tool
mii-tool command is used to check the link is activated or not. Most use of mii-tool command is to check to physical link of Ethernet card on command line. With this command you can check on command prompt that cable is plugged in LAN card or not.
ping
ping command is used to check the physical connectivity. If you get reply mean everything is ok. If you get request time out response means there is some problem it could be unplugged cable power off switch or enabled firewall on destination node. If you get Destination host unreachable means remote node is not in your network. Use CTRL+C to abort the ping sequenceservice network restart
Whatever change you made in network configuration files will not take place until you restart the network services. To implement change this command is used.How to use Linux as router
Exam question
Your system is going use as a router for 192.168.0.0/24 and 192.168.1.0/24. Enable the IP forwarding.
Linux as a Router
In this practical we are using three computers. One Linux system will be use for routing and reset two will remain in two different networks. First we will configure the system which is going to play the role of router.How to create virtual LAN card
Configure server system
You need two LAN card for routing between two networks or you can create virtual LAN card instead of deploying them physically.To create virtual Ethernet card change directory to /etc/sysconfig/network-scripts
ifcfg-eth0 is the necessary script file for Ethernet 0. Copy this file to the same folder to create new virtual LAN cards.
Now on this newly created virtual LAN card. It could be done by service network restart
Run setup command and select network configuration sub window from list
You have two LAN card here, select eth0 from list to assign IP
Now select eth0.1 ( This our virtual LAN card which we create in our last sections)
Set its IP to 192.168.0.254 This will be the default gateway of other network. Click on OK then quit and quit to come back on command prompt
IP forwarding can be enabled by editing in /etc/sysctl.conf file. open this file
Locate the net.ipv4. ip_forward = 0 tag. and replace the value 0 to 1. This will enable IP forwarding to permanently . But this require a system reboot.
If don't want to restart the system you can tell running kernel directly by echo command and kernel will enable the IP forwarding
now configure our client system. we are using two system one from each network to test the connectivity .
Our first system is a Linux machine run setup command on it
assign its IP address to 192.168.0.1 with a default gateway of 192.168.0.254
now restart the network service and check connectivity form its default gateway ( Server IP)
Now go on our other host which we are using a window machine ( You can also use Linux host ) and set IP address to 192.168.1.1 with a default gateway to 192.168.1.254
now open command prompt and test connectivity with default gateway
At this point you have completed all necessary step's to enable routing its time to verify this
Test from windows system
ping the Linux host located on other networkTest from Linux system
ping the Window host located on other networkConfigure linux server to deny icmp ping request
In this article I will show that how can you block ICMP ping request
We will use to two system for this practical. Go on first Linux system and set IP address to 192.168.0.254
Apply new IP by service network restart command and verify it ifconfig
verify new ip by ipconfig
Test connectivity with server by ping commands
You will get reply because all Linux servers are by default configured to response on ICMP ping request.
Now go back on Linux server and configure it to deny ping request.
We need to add deny tag in sysctl.conf file open /etc/sysctl.conf file
Now add net.ipv4.icmp_echo_ignore_all = 1 line in the end of file and save this file
Now try to ping form other system again you will not get replay now
Now other system cannot ping the Linux server but Linux server can ping ohter system as so far our other system have no such service configured. Go on Linux server and pingother system
After doing practical don't forget remove net.ipv4.icmp_echo_ignore_all = 1 line form sysctl.conf on server. Otherwise you will not get replay form server that not good at least in classroom lab.
Network configuration in Linux
Check LAN card driver is installed or not.
LAN driver is the top most part for network. To check it run setup commandSelect network configuration from list
If you see LAN card here mean you have LAN driver
if you don't see here anything and Linux drop you back on list manu means you don't have LAN driver. Install is first.
Check proper IP configuration
All systems on RHCE exam should have an properly configured IP address. During this entire practical we are using three systems. There description is given below Check these systems for properly configured IP address.Node | Operating system | Name | IP |
PC1 | Linux RHEL | Server | 192.168.0.254 |
PC2 | Linux RHEL | Client1 | 192.168.0.1 |
PC3 | Windows XP | Client2 | 192.168.0.2 |
Change host name
If you have skipped hostname during installation then it would be localhost.localdomain. You can change hostname with hostname command but this change would be temporary. To change hostname permanently do editing in /etc/sysconfig/network.set computer name as shown in table.
#vi /etc/sysconfig/network
On server system set it to Server and in client system set it Client1
Check /etc/hosts files for name resolution
Several Linux server depend name resolution. This file should have entry of all network systems. It will save you from naming related problem. In our network it should look like this on both Linux system Server and Client1Check firewall status
Firewall is the necessary security part of Linux system which is connected to Internet. But in exam we are not going to use Internet so it’s good practice to disable it.To disable firewall run setup commands
Now select firewall configuration from list and click on run tool
Select disable and click on ok and quit to return on command prompt.
System reboot require to take effect so reboot system with reboot -f commands
Check portmap and xinetd package status
Almost every Linux server needs these two rpm to function properly. First check that these rpm are install or not. If no rpm is install then install them via rpm commands.If you have rpm then check there status via setup commands
Now select system service from menu
put a star in front the portmap service
Now put star in front the xinetd service
Click on ok and select quit to come back on command prompt
Now restart these two service.
To keep on these services after reboot on then via chkconfig command
After reboot verify their status. It must be in running condition
Once you have successfully completed these steps you are ready to configure the Linux server
How to configure ssh server in Linux
On the other hand, all data transferred using OpenSSH tools is encrypted, making it inherently more secure. The OpenSSH suite of tools includes ssh for securely logging in to a remote system and executing remote commands, scp for encrypting files while transferring them to a remote system, and sftp for secure FTP transfers.
OpenSSH uses a server-client relationship. The system being connected to is referred to as the server. The system requesting the connection is referred to as the client. A system can be both an SSH server and a client. OpenSSH also has the added benefits of X11 forwarding and port forwarding.
X11 forwarding, if enabled on both the server and client, allows users to display a graphical application from the system they are logged in to on the system they are logged in from.
Port forwarding allows a connection request to be sent to one server but be forwarded to another server that actually accepts the request.
In this article we will discusses how to use OpenSSH, both from the server-side and the client-side.
Configuring the ssh Server
The openssh-server RPM package is required to configure a Red Hat Enterprise Linux system as an OpenSSH server. If it is not already installed, install it with rpm commands as described in our pervious article. After it is installed, start the service as root with the command service sshd start . The system is now an SSH server and can accept connections. To configure the server to automatically start the service at boot time, execute the command chkconfig sshd on as root. To stop the server, execute the command service sshd stop. To verify that the server is running, use the command service sshd status.Configure ssh server
In this example we will configure a ssh server and will invoke connection from client side.For this example we are using two systems one linux server one linux clients . To complete these per quest of ssh server Follow this link
Network configuration in Linux
- A linux server with ip address 192.168.0.254 and hostname Server
- A linux client with ip address 192.168.0.1 and hostname Client1
- Updated /etc/hosts file on both linux system
- Running portmap and xinetd services
- Firewall should be off on server
Now check sshd, portmap, xinetd service in system service it should be on
#setup Select System service from list [*]portmap [*]xinetd [*]sshd
To keep on these services after reboot on then via chkconfig command
After reboot verify their status. It must be in running condition
Create a normal user named vinita
On Linux client
ping from ssh server and run ssh command and give root passwordBy default ssh command will enable root session. If you want to login from normal user then specify his name with -l options.
With ssh you can run any command on server without login (user password require)
How to configure FTP Server in Linux
Any Linux system can operate as an FTP server. It has to run only the server software—an FTP daemon with the appropriate configuration. Transfers are made between user accounts on client and server systems. A user on the remote system has to log in to an account on a server and can then transfer files to and from that account's directories only.
A special kind of user account, named ftp, allows any user to log in to it with the username “anonymous.” This account has its own set of directories and files that are considered public, available to anyone on the network who wants to download them.
The numerous FTP sites on the Internet are FTP servers supporting FTP user accounts with anonymous login. Any Linux system can be configured to support anonymous FTP access, turning them into network FTP sites. Such sites can work on an intranet or on the Internet.
Configuring the ftp Server
The vsftpd RPM package is required to configure a Red Hat Enterprise Linux system as an ftp server. If it is not already installed, install it with rpm commands as described in our pervious article. After it is installed, start the service as root with the command service vsftpd start . The system is now an ftp server and can accept connections. To configure the server to automatically start the service at boot time, execute the command chkconfig vsftpd on as root. To stop the server, execute the command service vsftpd stop. To verify that the server is running, use the command service vsftpd status.Configure vsftpd server
In this example we will configure a vsftpd server and will transfer files from client side.For this example we are using three systems one linux server one linux clients and one windows xp clients. To complete these per quest of ftp server Follow this link
Network configuration in Linux
- A linux server with ip address 192.168.0.254 and hostname Server
- A linux client with ip address 192.168.0.1 and hostname Client1
- A window client with ip address 192.168.0.2 and hostname Client2
- Updated /etc/hosts file on both linux system
- Running portmap and xinetd services
- Firewall should be off on server
We suggest you to review that article before start configuration of ssh server. Once you have completed the necessary steps follow this guide.
Three rpm are required to configure ssh server. vsftpd, portmap, xinetd check them if not found then install
Now check vsftpd, portmap, xinetd service in system service it should be on
#setup Select System service from list [*]portmap [*]xinetd [*]vsftpd
To keep on these services after reboot on then via chkconfig command
After reboot verify their status. It must be in running condition
Create a normal user named vinita
Login for this user on other terminal and create a test file
On Linux client
ping from ftp server and run ftp command and give username and passwordafter login you can download files from the specified directories
Most commonly commands used on ftp prompt are
put To upload files on server get To download files from server mput To upload all files mget To download all files ? To see all available command on ftp prompts cd To change remote directory lcd To change local directory.
On window clients
Now go on window clients and create a file. copy con command is used to create files on window. To save use CTRL+ZNow ping from ftp server and invoke ftp session from server, login from user account and download as well as uploads files
Enable root account for ftp session and set permission on user
By default on vsftpd server root account is disable. You cannot login from root account.Now we will enable root account for ftp session and same time we will disable our normal user vinita to use ftp sessions.
open file /etc/vsftpd/ftpusers . Users whose name are set in this file will not allowed to login from ftp.
By default this file have an entry for root that why root are not allowed to use ftp. remove root from list and add user vinita
Now remove entry form /etc/vsftpd/user_list files. Users whose names are set in this file are also not allowed to login from ftp even they are not prompt for password.
By default this file have an entry for root that way root is denied form login even not asked for password remove root from list and add user vinita
After saving change in these files restart the vsftpd service
Now go on client system and login from root this time root will login
Now try to login form user vinita she should not prompt form password also
How to set login banner for ftp server
To set login banner open /etc/vsftpd/vsftpd.conf file and search for this tagUncomment this tag and set your banner and save file , and restart the vsftpd service
Go on client system and check banner it will appear before user login
How to configure NIS Server in Linux
RHCE exam questions
One NIS Domain named rhce is configured in your lab, server is 192.168.0.254. nis1, nis2,nis3 user are created on domain server. Make your system as a member of rhce domain. Make sure that when nis user login in your system home directory should get by them. Home directory is shared on server /rhome/nis1.RHCE exam doesn't ask candidate to configure NIS server. It test only NIS client side configuration. As you can see in example questions. But here in this article we will configure both server and client side for testing purpose so you can get more depth knowledge of nis server
Configure NIS server
In this example we will configure a NIS server and a user nis1 will login from client side.For this example we are using two systems one linux server one linux clients . To complete these per quest of nis server Follow this link
Network configuration in Linux
- A linux server with ip address 192.168.0.254 and hostname Server
- A linux client with ip address 192.168.0.1 and hostname Client1
- Updated /etc/hosts file on both linux system
- Running portmap and xinetd services
- Firewall should be off on server
Now check nfs,ypserv,yppasswdd,ypbind, portmap, xinetd service in system service it should be on
#setup Select System service from list [*]portmap [*]xinetd [*]nfs [*]ypserv [*]yppasswdd [*]ypbind
Set hostname and NIS domain name as shown here and save file
Now create a user named nis1 and give his home directory on /rhome with full permission
Now open /etc/exports file
share /rhome/nis1 directory for network
save this with :wq and exit
now open /var/yp/Makefile file
and locate line number 109 [ use ESC + : +set nu command to show hidden lines or read our vi editor article to know more about vi command line option ]
Now remove other entry from this line excepts passwd group hosts netid \ [as shown here]
save this with :wq and exit
Now restart these service
#service portmap restart #service xinetd restart #service nfs restart #service ypserv restart #service yppasswdd restart
Now change directory to /var/yp and run make command to create database
now update this database by running this commands [ first add server and then add all client machine one by one. After adding press CTRL+D to save, confirm by pressing y]
Now once again restart all these service this time there should be no error
#service portmap restart #service xinetd restart #service nfs restart #service ypserv restart #service yppasswdd restart #service ypbind restart
#chkconfig portmap on #chkconfig xinetd on #chkconfig nfs on #chkconfig ypserv on #chkconfig yppasswdd on #chkconfig ypbind on
Client configuration
Before you start client configuration we suggest you to check proper connectivity between server and client. First try to login on NIS server from telnet. If you can successfully login via telnet then try to mount /rhome/nis1 directory via nfs server. If you get any error in telnet or nfs then remove those error first. You can read our pervious article for configuration related help.To know how configure nfs server read
How to configure nfs server in Linux
To know how configure telnet server read
How to configure telnet server in Linux
Once you successfully completed necessary test then start configuration of client sides.
Two rpm are required to configure clients yp-tools and ypbind check them for install
now open /etc/sysconfig/network file
and make change as shown here
save the file with :wq and exit
now run setup command and select authentication configuration from list
#setup
now check mark on NIS and enter on next
Set domain name to rhce and server to 192.168.0.254 and click on ok
No error should be occurred here if you see any error then check all configuration.
no open /etc/auto.master file
in the end of file do editing of /rhome as shown here
save the file with :wq and exit
now open /etc/auto.misc file
in the end of file do editing of user nis1 as shown here
save the file with :wq and exit
now restart autofs and ypbind service
set these service on via chkconfig commands
#chkconfig autofs on #chkconfig ypbind on
#reboot -f
How to configure dhcp server in Linux
The DHCP clients request an IP address and other network settings from the DHCP server on the network. The DHCP server in turn leases the client an IP address within a given range or leases the client an IP address based on the MAC address of the client's network interface card (NIC). The information includes its IP address, along with the network's name server, gateway, and proxy addresses,including the netmask.
Nothing has to be configured manually on the local system, except to specify the DHCP server it should get its network configuration from. If an IP address is assigned according to the MAC address of the client's NIC, the same IP address can be leased to the client every time the client requests one. DHCP makes network administration easier and less prone to error.
Exam Question Configure the DHCP server by matching the following conditions:
- Subnet and netmask should be 192.168.0.0 255.255.255.0
- Gateway Should be 192.168.0.254
- DNS Sever Should be 192.168.0.254
- Domain Name should be example.com
- Range from 192.168.0.10-50
Configure dhcp server
In this example we will configure a dhcp server and will lease ip address to clients.For this example we are using three systems one linux server one linux clients and one window clients.
dhcp rpm is required to configure dhcp server. check it if not found then install
Now check dhcpd service in system service it should be on
#setup Select System service from list [*]dhcpd
To assign IP to dhcp server
DHCP server have a static a ip address. First configure the ip address 192.168.0.254 with netmask of 255.255.255.0 on server.Run setup command form root user
#setup
this will launch a new window select network configuration
now a new window will show you all available LAN card select your LAN card ( if you don't see any LAN card here mean you don't have install driver)
assign IP in this box and click ok
click on ok, quit and again quit to come back on root prompt.
restart the network service so new ip address can take place on LAN card
#service network restart
now open /etc/dhcpd.conf
default entry in this file look like this
make these change in this file to configure dhcp server
remove this line # - - - default gateway set option routers to 192.168.0.254 set option subnet-mask to 255.255.255.0 option nis domain to example.com option domain-name to example.com option domain-name-servers to 192.168.0.254 range dynamic-bootp to 192.168.0.10 192.168.0.50;
how to assign fix ip address to any host
locate this paragraph and change hardware Ethernet to client's mac address and fixed -address to ip address which you want to provide that hostafter making necessary change save file and exit
now create a blank file use to store the allocated ip address information
Now restart dhcpd service and on it with chkconfig commands
Linux Client configuration
Client configuration is very easy and straightforward. All you need to do is set ip address to dynamic in the properties of lan card. In linux#setup select network configuration from menu list Select lan card and enter on ok Select USE DHCP and enter on ok Now click on quit and quit to come back on root prompt
Window Client configuration
To configure windows system as dhcp clients open lan card properties and select tcp/ip and click on properties and set obtain ip address automaticallyGo on command prompt and check new ip address
Check lease on DHCP server
you can check allocated address on server.How to configure web server in Linux
Exam question 1 There are two sites www.vinita.com and www.nikita.com. Both sites are mappings to 192.168.0.X IP address where X is your Host address. Configure the Apache web server for these sites to make accessible on web
Configure web server
In this example we will configure a web server.necessary rpm for web server is httpd, httpd-devel and apr check them for install
Now configure the ip address to 192.168.0.254 and check it
start httpd daemons and verify its running status
Configure virtual hosting
In this example we will host a website www.vinita.com to apache web server. create a documents root directory for this website and a index pagefor testing purpose we are writing site name in its index page
save file and exit
now open /etc/hosts file
in the end of file bind system ip with www.vinita.com
now open /etc/httpd/conf/httpd.conf main configuration file of apache server
locate virtual host tag
remove # from the beginning and add the IP of host
Now go in the end of file and copy last seven line [ virtual host tag ] and paste them in the end of file. change these seven lines as shown in image
now save this file and exit from it
you have done necessary configuration now restart the httpd service and test this configuration run links command
if links command retrieve your home page
means you have successfully configured the virtual host now test it with site name
In output of links command you should see the index page of site
Configure multiple site with same ip address
At this point you have configured one site www.vinita.com with the ip address 192.168.0.254. Now we will configure one more site www.nikita.com with same ip addresscreate a documents root directory for www.nikita.com website and a index page
for testing purpose we are writing site name in its index page
save file and exit
now open /etc/hosts file and bind system ip with www.nikita.com
now open /etc/httpd/conf/httpd.conf main configuration file of apache server
Now go in the end of file and copy last seven line [ virtual host tag ] and paste them in the end of file. change these seven lines as shown in image
now save this file and exit from it
you have done necessary configuration now restart the httpd service
test this configuration run links command
In output of links command you should see the index page of site
configure multiple site with multiple ip address
Now we will host multiple sites with multiple ip address. Create a virtual lan card on server and assign its an ip address of 192.168.0.253. we will create a testing site www.nidhi.com and will bind it with ip address of 192.168.0.253create a documents root directory for www.nidhi.com website and a index page
for testing purpose we are writing site name in its index page
save file and exit
now open /etc/hosts file and bind system ip with www.nidhi.com
now open /etc/httpd/conf/httpd.conf main configuration file of apache server
Now go in the end of file and copy last seven line [ virtual host tag ] and paste them in the end of file. change these seven lines as shown in image
now save this file and exit from it
you have done necessary configuration now restart the httpd service
test this configuration run links command
In output of links command you should see the index page of site
How to create site alias
Now I will show you that how can you use site alias to configure more name of same site. we configure a site www.vinita.com in stating of example. now we will create www.goswami.com site alias for this site so this site can be access with both name.To create alias first make its entry in /etc/hosts file as shown here
Now open main apache configuration /etc/httpd/conf/httpd.conf
Now go in the end of file and copy last seven line [ virtual host tag ] and paste them in the end of file. change these seven lines as shown in image
now save this file and exit from it
you have done necessary configuration now restart the httpd service and test this configuration run links command
In output of links command you should see the index page of site
0 comments:
Post a Comment