This article covers the main TCP/IP network configuration files used by Linux to configure various network services of the system such as IP Address, Default Gateway, Name servers - DNS, hostname and much more. Any Linux Administrator must be well aware where these services are configured and to use them. The good news is that most of the information provided on this article apply's to Redhat Fedora, Enterprise Linux, CentOS, Ubunto and other similar Linux distributions.
On most Linux systems, you can access the TCP/IP connection details within 'X Windows' from Applications > Others > Network Connections. The same may also be reached through Application > System Settings > Network > Configure. This opens up a window, which offers configuration of IP parameters for wired, wireless, mobile broadband, VPN and DSL connections:
The values entered here modify the files:
/etc /sysconfig/network-scripts/ifcfg-eth0
/etc /sysconfig/networking/devices/ifcfg-eth0
/etc /resolv . conf
/etc /hosts
The static host IP assignment is saved in /etc/hosts
The DNS server assignments are saved in the /etc/resolv . conf
IP assignments for all the devices found on the system are saved in the ifcfg -<interface> files mentioned above.
If you want to see all the IP assignments, you can run the command for interface configuration:
# ifconfig
Following is the output of the above command:
[root@gateway ~eth0 Link
inet6 addr: fe80::20c:29ff:feab:213e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets
TX packets
RX bytes
Interrupt:19 Base address
inet6
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets
TX packets
RX bytes
The command ifconfig is used to configure a network interface. It can be used to set up the interface parameters that are used at boot time. If no arguments are given, the command ifconfig displays the status of the currently active interfaces. If you want to see the status of all interfaces, including those that are currently down, you can use the argument -a , such as -
# ifconfig -a
Fedora, Redhat Enterprise Linux, CentOS and other similar distributions supports user profiles as well, with different network settings for each user. The user profile and its parameters are set by the network-configuration tools. The relevant system files are placed in:
/etc /sysconfig/netwroking /profiles/profilename /
After boot-up, to switch to a specific profile you have to access a graphical tool, which will allow you to select from among the available profiles. You will have to run:
$ system-config-network
Or for activating the profile from the command line -
$ system-config-network-cmd -p <profilename > --activate
THE BASIC COMMANDS FOR NETWORKING
The basic commands used in Linux are common to every distro :
Many distro are now including the iproute2 tools with enhanced routing and networking tools:
TYPES OF NETWORK INTERFACE
LO (local loop back interface). Local loopback interface is recognized only internal to the computer, the IP address is usually 127.0.0.1 or 127.0.0.2.
Ethernet cards are used to connect to the world external to the computer, usually named eth0, eth1, eth2 and so on.
Network interface files holding the configuration of LO and ethernet are:
/etc /sysconfig/nework -scripts/ifcfg-lo
/etc /sysconfig/nework -scripts/ifcfg-eth0
To see the contents of the files use the command:
# less /etc/sysconfig/network-scripts/ifcfg-lo
Which results in:
DEVICE=lo
IPADDR=127. 0.0.1
NETMASK=255. 0.0.0
NETWORK=127. 0.0.0
# If you're having problems with gated making 127.0.0.0/8 amartian ,
# you can change this to something else (255.255.255.255, for example)
BROADCAST=127. 255.255.255
ONBOOT=yes
NAME=loopback
IPADDR=127
NETMASK=255
NETWORK=127
# If you're having problems with gated making 127.0.0.0/8 a
# you can change this to something else (255.255.255.255, for example)
BROADCAST=127
ONBOOT=yes
NAME=loopback
And the following:
# less /etc/sysconfig/network-scripts/ifcfg-eth0
Which gives the following results:
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=00: 0C:29:52: A3: DB
TYPE=Ethernet
BOOTPROTO=none
IPADDR=192. 168.1.18
PREFIX=24
GATEWAY=192. 168.1.11
DNS1=8. 8.8.8
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=00
TYPE=Ethernet
BOOTPROTO=none
IPADDR=192
PREFIX=24
GATEWAY=192
DNS1=8
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
START AND STOP THE NETWORK INTERFACE CARD
The ifconfig command can be used to start and stop network interface cards:
# ifconfig eth0 up
# ifconfig eth0 down
The ifup & ifdown command can also be used to start and stop network interface cards:
# ifup eth0
# ifdown eth0
The systemctl commands can also be used to enable, start, stop, restart and check the status of the network interface services -
# systemctl enable network. service
# systemctl start network . service
# systemctl stop network. service
# systemctl restart network. service
# systemctl status network. service
DISPLAYING AND CHANGING YOUR SYSTEM'S HOSTNAME
The command hostname displays the current hostname of the computer, which is 'Gateway':
# hostnameGateway
You can change the hostname by giving the new name at the end of the command -
# hostname Firewall-cx
This will change to the new hostname once you have logged out and logged in again. In fact, for any change in the interfaces, the change is implemented only after the user logs in the next time after a log-out.
No comments:
Post a Comment