Linux - Network Settings
In this page we will discuss about how to set IP address on your machine.
Methods for assigning IP
We will study several methods to give IP address to my machine.
This file looks like this
IP address setting
This file already has the ip configuration because we already assigned Ip configuration in machine. You can change the IP address.
In Centos 5.x and RHEL 5.x you can take advantages of setup
IP address have been assigned by DHCP server ,will be discuss in later
When you assign the ip address to your machine
Use command to update your system.
[root@localhost~]# service network restart
[root@localhost ~]# /etc/init.d/network restart
The above method is applicable for RHEL and Centos Linux.
For Ubuntu and Debian Linux you can edit the /etc/networking/interfaces
When your machine has dynamic IP, provided by DHCP server, Then the file looks
IP address in Ubuntu and Debian
For static IP you can edit files like as given below.
iface lo inet loopback
# The primary network interface
iface eth0 inet static
Important files of Network settings
Here we will discuss about some file related to Networking.
The /etc/hosts file contains the IP address-to-hostname translation table. The /etc/hosts file on each member must contain entries for the following:
- IP addresses and associated hostnames for all cluster members
- IP addresses and associated hostnames for the point-to-point Ethernet heartbeat connections (these can be private IP addresses)
You can change your computer name as shown in below figure.
Hostname means your computer name ,this time ""mohitraj" is my computer name, you can edit it.
Here we will study some commands related to networking.
If want to know your network configuration
Redhat 6 sometime does not bringing up Ethernet card. If you face this problem then open the file /etc/sysconfig/network –scripts/ifcfg-eth0 check the options ONBOOT=yes
Make sure that it should be "yes", if it is "no" change this to "yes".
Reboot the system
To track what ports are open and what services are running on that ports.
[root@localhost /root]# netstat -natu
option is used to display both listening and non listening ports.
option is used to display TCP ports.
option is used to display UDP ports.
option is used, not to resolve hostnames from IP addresses