After installing Operating System the first thing come into mind, how to modify network setting of your Linux Box. Network management is really simple when it comes to CentOS/RHEL/fedora, Most of the setting is easy and simple to adjust. We need to modify few files to configure our networking, as most of the configuration kept in files.
`
LAB Scenario:
I have just installed one fresh system having CentOS 6.5 with basic installation.
Four Basic changes we are going to do.
1 – Host Name = lx.broexperts.com
2 – IP Address = 192.168.1.199/255.255.255.0
3 – Gateway  = 192.168.1.1
4 – DNS Â = 192.168.1.1
Before we get into setting up Linux networking on a CentOS system , First lets we see some network management commands to verify our current network configuration.
Command | Explanation |
Ifconfig -a | This command will show current ip address and other interface-related information, with –a switch we can see all attached network interfaces of system. |
Route | enable you to view and change the routing information on the linux box. |
System-network-config-tui | Provides a menu-driven utility for network configuration |
There are some additional files that you need to know, when you are configuring network interface.
File Path | Explanation |
/etc/sysconfig/network | This file contains gateway and hostname information. |
/etc/sysconfig/network-scripts | This directory contains all the interface config files for your system |
Display currently attached network interfaces status with below command.
Out Put
There is no IP address assigned on “eth0”
Step -1 Change IP address on “eth0”
Above screenshot shows the current parameters in the configuration file, We will change parameters,
adding ip address and subnetmask see below:
Changes are marked with yellow box.
Now save and exit pressing “:wq†without quotes.
Step-2 Assign Gateway & Hostname
We are going to edit one file to change hostname and default gateway.
Current Contents of ‘/etc/sysconfig/network’ file:
We need to change in this way:
Save and exit “:wq†without quotes.
Step-3 Assign DNS
File will be empty if you didn’t configure dns server address.
Will assign our dns server address in this way:
Save and exit “:wq†without quotes.
TIP: if you want to hostname changing without restarting system, then we have to give one additional command:
“hostname DesireHostName†and relogin on the terminal see below:
Now logout and login again.
That’s all now time to restart network service to make our changes in action.
Here is command:
Then lets again put ifconfig –a command to verify our network changing is take effect or not.
Step 4: Lets verify internet access on our linux box.
Here we go… we are able to reach on internet ….
Comments are freee 🙂 !