Linux Network Configuration

Linux Network Configuration in Linux/Centos


Today we will see in this post that How to set up network configuration in Linux/centos such as How to assign Static ip address, How to assign gateway, how to assign DNS, How to change hostname in linux. It's very easy to assign static ip address, DNS, Gateway and Host name. Please read full articles if you face any problem regarding this articles so please leave comments or drop email within 24 hours you will get reply by our team.

Please leave comment if article good and share it also.



To check hostname in Linux/Centos:

[root@localhost ONS]# hostname

To change hostname temporary in Linux/Centos:

[root@localhost ONS]# hostname newhostname

To change hostname permanent in Linux/Centos:

[root@localhost ONS]# vim /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=localhost.local --------> please change localhost.local into newhostname.local (according to your requirement)

To restart network service in Linux/Centos:

[root@localhost ONS]# service network restart



To check ip address in Linux/Centos:

[root@localhost ONS]# ifoconfig

To assign static ip address temporary in Linux/Centos:

[root@localhost ONS]# ifconfig eth0 192.168.1.250 netmask 255.255.255.0

To assign static ip address permanent in Linux/Centos:

[root@localhost ONS]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

View this detail

DEVICE="eth0"
BOOTPROTO="DHCP" 
HWADDR="00:0C:29:56:4E:9E"
MTU="1500"
NM_CONTROLLED="yes"
ONBOOT="yes"

Change some configuration:

DEVICE="eth0"
BOOTPROTO="static"
HWADDR="00:0C:29:56:4E:9E"
IPADDR=192.168.1.253
NETMASK=255.255.255.0 or PREFIX=24
MTU="1500"
NM_CONTROLLED="yes"
ONBOOT="yes"

To restart network service in Linux/Centos: 

[root@localhost ONS]# service network restart

To assign Gateway ip address in Linux/Centos: 

[root@localhost ONS]# vim /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=localhost.local
GATEWAY=192.168.1.1

To assign DNS ip address in Linux/Centos:

[root@localhost ONS]# vim /etc/resolv.conf

nameserver 192.168.1.1 or 8.8.8.8

To restart network service in Linux/Centos: 

[root@localhost ONS]# service network restart

Note: Please don't forgot to restart service of network because it will update own recent changes.

Hope this will help to all of you and resolved your all query if you have any query or question so you may ask on email our email account (onlinenetworkssolution@gmail.com) or leave comment on page.

Share:

2 comments

  1. Whenever I need some command then I visit your side and I find my problem in this website and I appreciate,thanks your sir for providing knowledge related to this problem for solving... Thanks a lots sir ji

    ReplyDelete

Please leave your comments...... Thanks