Networking In Linux
Descriptions:
Any system if needed to connect to the Internet, would require the networking components configured. Linux offers various methods to control the network interfaces of a system which will be explored .
Linux provides excellent support for networking and configuration of the various options via the command line as well as built-in configuration tools.
Gathering network information and setting IP addresses:
- The first step is to find the IP address and the currently active interfaces in the system that we are using. Use the command 'ifconfig' to get a list of all active interfaces in the system.
#ifconfig
eth0 Link encap:Ethernet HWaddr b8:ac:6f:b5:8a:3a
inet addr:10.112.18.76 Bcast:10.112.255.255 Mask:255.255.0.0
inet6 addr: fe80::baac:6fff:feb5:8a3a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:110687304 errors:0 dropped:0 overruns:0 frame:0
TX packets:84807708 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3862591144 (3.8 GB) TX bytes:2051180865 (2.0 GB)
Interrupt:18
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1098 errors:0 dropped:0 overruns:0 frame:0
TX packets:1098 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:610070 (610.0 KB) TX bytes:610070 (610.0 KB)
- We assign an IP address to the interface 'eth0' using the command line as follows :
we also check if the changes have taken place using the 'ifconfig' command. You may not give the subnet mask value if you want the default ones to be used.
#ifconfig eth0
- However this assignment of the IP address is only a temporary one and will be lost upon the next system reboot or restart of the network services.
- To prevent this from happening and the avoid the setting of the IP address for each session, edit the configuration file for the interface which is located in the '/etc/sysconfig/network-script' directory. The file will be called 'ifcfg-
'. In our example, the file will be called 'ifcfg-eth0'.
- Edit the lines in the original file which is as follows:
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=08:0027:27:57:52
ONBOOT=yes
TYPE=Ethernet
To read as follows
DEVICE=eth0
BOOTPROTO=static
HWADDR=08:0027:27:57:52
ONBOOT=yes
TYPE=Ethernet
IPADDR= 192.168.1.1 --------------------------------------> IP address
NETMASK= 255.255.2555.0 ---------------------------> subnet mask
- From the next boot onward the system will take the IP address that you designated.
Adding and Deleting gateway in Linux:
- The IP address assigned so far would only allow for communication between system in the same subnet. To add support for communications to other subnets, we need to add gateways to the system.
- We add default gateway to the system by using the 'route' command.
- We can add a dedicated route to a particular network or host by issuing the route command but with a few changes to the command used above.
#route add -host 172.16.1.1 gw 192.168.1.11
- To look at the current routing table in the kernel we use the same command but this time without any arguments. However we can use the '-n' switch which will give the output in the numeric format.
- To delete a route we use the 'route' command itself but with the 'del' option passed instead of the 'add'.
- A look at the kernel routing table shows that the route to the 10.0.0.0/32 network no longer exists.
Using the 'system-config-network' tool:
- Open a terminal and type 'system-config-netowrk'
- In the monitor we will see network configuration tool Utility.
- Select the interface whose properties you wish to change and click edit. A screen as shown on monitor.
- Choose the properties of the interface as per your requirements.
- To add route to the system click on the Route tab.
- Click on 'Add' icon and you will configure IP address and Subnet Mask , Gateway.
- Finally you can delete a route by selecting the route and then clicking 'Delete' in the 'Route' tab.
No comments:
Post a Comment