€¦ · Web viewUse this to set the gateway that is used for traffic on this network card. If the...
Transcript of €¦ · Web viewUse this to set the gateway that is used for traffic on this network card. If the...
MOBILE ITnTSolutions, LLC.
Linux Systems Administrator
Program
Class Notes:
“Connecting to the Network”Part II
Connecting to the Network – Part II
Configuring the Network with NetworkManager: The easiest way to configure the network is by clicking the
NetworkManager icon on the graphical desktop of your server In this section, we will learn how to set network parameters
using the graphical tool You can find the NetworkManager icon in the upper-right
corner of the graphical desktopo It provides an overview of all currently available
network connections, including Wi-Fi networks to which your server is not connected
Right-click the NetworkManager icon, select Edit Connections to set the properties for your server’s network connections
o All the wired network connections are on the Wired tabo Name of the connection you’re using depends on the
physical location of the deviceo Older versions of RHEL names like “eth0” and “eth1”
were usedo RHEL 6.2 and newer uses device-dependent names like
“p6p1” On servers with many network cards, it can be hard to find
the specific device you needo However, if your server has only one network card
installed, it is not that hard. . .just select the network card that is listed on the Wired tab … See
o Below:
Network Connections dialog box:
To configure the network card, select it on the Wired tab and click Edit
You should see a window that has four tabso The most important tab is IPv4 Settingso On this tab, you’ll see the current settings for the
IPv4 protocol that is used to connect to the networko By default, your network card is configured to obtain
an address from a DHCP servero As an administrator, you’ll need to know how to set the
address you want to use manually Select “manual” from the drop-down list: see pic
below:
Setting an IPv4 address manually
Now click “Add” to insert a fixed IPv4 addresso Type the IP addresso Type the “netmask” needed for your network as well as the
“gateway address” You must enter the netmask address in CIDR format and
not in the dotted format For example, instead of 255.255.255.0, use 24
o Enter IP address of the DNS server that used in your network
o Click “Apply”o Now, close the NetworkManager interface to write the
configuration to the configuration files and activate the new address immediately
Understanding NetworkManager Configuration Files
Whether you use the graphical NetworkManager or the text-based system-config-network, the changes you make are written to the same configuration file for each network interface on your server
o The name of all these files start with “ifcfg-“ and are followed by the names of the specific network ards
o If you card is known as “p6p1”, it’s configuration is stored in “/etc/sysconfig/network-scripts/ifcfg-p6p1” (see pic)
Network configuration files are stored in /etc/sysconfig/network-script
In the network config scripts, variables are used to define different network settings
See example below of the configuration for the network card p6p1:
See table below that list/describe some of the variables shown above:
Parameter ValueDEVICE Specifies the name of the device, as it is known on this server.
NM_CONTROLLED Specifies whether the device is controlled by the NetworkManager service, which is the case by default.
ONBOOT Indicates that this device is started when the server boots.TYPE Indicates the device type, which typically is Ethernet.
BOOTPROTO Set to dhcp if the device needs to get an IP address and additional configuration from a DHCP server. If set to anything else, a fixed IP address is used.
DEFROUTE If set to yes, the gateway that is set in this device is also used as the default route.
IPV4_FAILURE_FATAL Indicates whether the device should fail to come up if there is an error in the IPv4 configuration.
IPV6INIT Set to yes if you want to use IPv6.NAME Use this to set a device name.
UUIDAs names of devices can change according to hardware configuration, it might make sense to set a universal unique ID (UUID). This UUID can then be used as a unique identifier for the device.
HWADDR Specifies the MAC address to be used. If you want to use a different MAC address than the one configured on your network card, this is where you should change it.
IPADDR Defines the IP address to be used on this interface.
PREFIXThis variable defines the subnet mask in CIDR format. The CIDR format defines the number of bits in the subnet mask and not the dotted decimal number, so use 24 instead of 255.255.255.0.
GATEWAYUse this to set the gateway that is used for traffic on this network card. If the variable DEFROUTER is also set to yes, the router specified here is also used as the default router.
DNS1This parameter specifies the IP address of the first DNS server that should be used. To use additional DNS servers, use the variables DNS2 and, if you like, DNS3 as well.
USERCTL Set to yes if you want end users to be able to change the network configuration. Typically, this is not a very good idea on servers.
Understanding Network Service Scripts: The network configuration on RHEL is managed by the
NetworkManager serviceo This service doesn’t require much management, because
it is enabled by defaulto While it is commonly necessary to restart a service
after changing the configuration, this is not the case for NetworkManager
Apart from the NetworkManager service (/etc/init.d/NetworkManager), there’s also the network service (/etc/init.d/network)
o The network service is what enables all network cards on your server
o If you stop it, all networking on your server will be ceased
The NetworkManager service is used for managing the network cards.
o Stopping NetworkManager service doesn’t stop networking: it just stops the NetworkManager program, which means you would need to fall back to manual management of the network interface on your server
Configuring Networking from the Command Line: In all cases, your server should be configured to start the
network interfaces automatically In many cases, however, it’s also useful if you can manually
create a configuration for a network card This is especially useful if you’re experiencing problems
and want to test whether a given configuration works before writing it out to a configuration file
The classic tool for manual network configuration and monitoring is “ifconfig”
o This command provides an overview of the current configuration of all network cards, including some usage statistics that show how much traffic has been handled by a network card since it was activated
o See example below:
[root@hnl ∼]# ifconfiglo 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:212 errors:0 dropped:0 overruns:0 frame:0 TX packets:212 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:16246 (15.8 KiB) TX bytes:16246 (15.8 KiB)p6p1 Link encap:Ethernet HWaddr B8:AC:6F:C9:35:25 inet addr:192.168.0.70 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::baac:6fff:fec9:3525/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:4600 errors:0 dropped:0 overruns:0 frame:0 TX packets:340 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:454115 (443.4 KiB) TX bytes:40018 (39.0 KiB) Interrupt:18wlan0 Link encap:Ethernet HWaddr A0:88:B4:20:CE:24 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Even if the “ifconfig” output is easy to read, you shouldn’t use “ifconfig” anymore on modern Linux distributions such as RHEL
For about some years now, the “ip” tool is the default instrument for manual network configuration and monitoring
Exercise: Configuring a Network Interface with ip (see attach)
AFTER Completion of Exercise: One reason many administrators dislike the “ip” command is
because it’s not very easy to use This is because the “ip” command works with subcommands,
known as “objects” in the help for the command
Using these objects makes the “ip” command very versatile but complex at the same time
If you type “ip help”, you’ll see a help message showing all the objects that are available with the “ip” command
See example:
Many objects are available, but only 3 are interesting:o ip link (used to show link statistics)o ip addr (show and manipulate the IP addresses of
network interfaces)o ip route (can be used to show and manage routes on your
server) The design of IP routing allows for very simple
route definitions for small networks, while not hindering the flexibility of routing in complex environments.
A key concept in IP routing is the ability to define what addresses are locally reachable as opposed to not directly known destinations.
Every IP capable host knows about at least three classes of destination: itself, locally connected computers and everywhere else
Managing Address Configuration: to manage the current address allocation of a device, you
use “ip addr” to set the IP address, you need “ip addr add” followed by
the name of the device and the address you want to set
o Make sure the address is always specified with the subnet mask you want to use
To add an IP address such as 192.168.0.72 to the network device with the name “p6p1”, you would use the following command:
o ip addr add dev p6p1 192.168.0.72/24 To delete an IP address
o ip addr del dev p6p1 192.168.0.72/24
Managing Routes: To communicate on a network, your server needs to know which
node to use as the default gateway, also known as the “default router”
To see current settings, use “ip route show” command See example below
On a typical server, you won’t see much routing information There’s only one direct route for the networks to which your
server is directly connectedo This is shown in the first line in the example above,
where the network 192.168.0.0 is identified with the scope link and accessible through the network card p6p1
Apart from directly connected routers, there should be a default route on every server
As shown above, you can see the default route is the node with IP address 192.168.0.254
o This means that all traffic to networks that are not directly connected to this server are sent to IP address 192.168.0.254
As a server administrator, you occasionally need to set a route from the command line
o To do this, use “ip route add” command, followed by the required routing information
o Typically, you need to specify in this routing information which host is identified as a router and which network card is used on this server to reach this host
o Thus, if there is a network 10.0.0 that can be reached through IP address 192.168.0.253, which is accessible through the network card p6p2, you can add the route using “ip route add 10.0.0 via 192.168.0.253 dev p6p2”
o Note: nothing you do with the “ip” command is automatically saved. . .This means that if you restart a network card, you will lose all the information you’ve manually set using “ip”…
The drawback of 'ip' or 'route' command is that, when Linux reboots it will forget static routes.
So store them in configuration file. CENTOS: cat /etc/sysconfig/network
Sample:
Additional Content Resource:http://www.cyberciti.biz/faq/howto-linux-configuring-default-route-with-ipcommand/ persistent routing source:http://www.cyberciti.biz/tips/configuring-static-routes-in-debian-or-red-hat-linux-systems.html