Network configuration


Published on

This ppt allows you to configure network on linux redhat

Published in: Education
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Network configuration

  1. 1. Linux RedhatNetworkConfiguration
  2. 2. ifconfigIfconfig or ifconfig -a
  3. 3. #Ifconfig eth0 down #Ifconfig eth0 up == #service network restart To configure a static IP:#ifconfig eth0 netmask broadcast192.168.10.255 up
  4. 4. Default route(Default Gateway)# route add default gw {IP-ADDRESS} {INTERFACE-NAME}#route add default gw eth0
  5. 5. static route#ip route show this is a command to show you the default gatewayand the ipYou can add static route using following command:#ip route add {NETWORK} via {IP} dev {DEVICE}For example network available via192.168.1.254:# ip route add via dev eth1Alternatively, you can use old good route command:# route add -net netmask gw192.168.1.254 dev eth1
  6. 6. Network Configuration Files
  7. 7. /etc/hostsThe main purpose of this file is to resolve hostnames that cannot be resolvedany other way. It can also be used to resolve hostnames on small networkswith no DNS server./etc/resolv.confThis file specifies the IP addresses of DNS servers and the search domain./etc/sysconfig/networkThis file specifies routing and host information for all network interfaces./etc/sysconfig/network-scripts/ifcfg-<interface-name>For each network interface, there is a corresponding interface configurationscript. Each of these files provide information specific to a particularnetwork interface.
  8. 8. /etc/sysconfig/networkThe /etc/sysconfig/network file is used to specify information about the desirednetwork configuration. The following values may be used:• NETWORKING=<value>, where <value> is one of the following boolean values:yes — Networking should be — Networking should not be configured.• HOSTNAME=<value>, where <value> should be the Fully Qualified DomainName (FQDN), such as, but can be whateverhostname is necessary.• GATEWAY=<value>, where <value> is the IP address of the networks gateway.
  9. 9. /etc/sysconfig/networkStatic IP address Configuration: (Configure gateway address)NETWORKING=yesHOSTNAME=my-hostname -Hostname is defined here and by command hostnameGATEWAY="XXX.XXX.XXX.YYY" - Used if your network is connected to another network or the internet.OR for DHCP client configuration:NETWORKING=yesHOSTNAME=my-hostname - Hostname is defined here and by commandhostname
  10. 10. /etc/sysconfig/network-scripts/ifcfg-<interface-name>The following is a sample ifcfg-eth0 file for a system using a FIXEDIP address:DEVICE=eth0BOOTPROTO=noneONBOOT=yesNETWORK=, using DHCP server:# Intel Corporation 82540EM Gigabit Ethernet ControllerDEVICE=eth0BOOTPROTO=dhcpHWADDR=08:00:27:FF:FB:FEONBOOT=yes
  11. 11. Below is a listing of the configurableparameters in an Ethernet interfaceconfiguration file:/etc/sysconfig/network-scripts/ifcfg-<interface-name>
  12. 12. BOOTPROTO=<protocol>where <protocol> is one of the following:• none — No boot-time protocol should be used.• bootp — The BOOTP protocol should be used.• dhcp — The DHCP protocol should be used.DEVICE=<name>where <name> is the name of the physical device (except fordynamically-allocated PPP deviceswhere it is the logical name).DNS{1,2}=<address>where <address> is a name server address to be placed in/etc/resolv.conf if thePEERDNS directive is set to yes.
  13. 13. GATEWAY=<address>where <address> is the IP address of the network router or gateway device(if any).HWADDR=<MAC-address>where <MAC-address> is the hardware address of the Ethernet device in theformAA:BB:CC:DD:EE:FF. This directive must be used in machines containingmore than one NIC to ensure that the interfaces are assigned the correctdevice names regardless of the configured load order for each NICsmodule. This directive should not be used in conjunction with MACADDR.IPADDR=<address>where <address> is the IP address.NETMASK=<mask>where <mask> is the netmask value.
  14. 14. ONBOOT=<answer>where <answer> is one of the following:• yes — This device should be activated at boot-time.• no — This device should not be activated at boot-time.USERCTL=<answer>where <answer> is one of the following:• yes — Non-root users are allowed to control this device.• no — Non-root users are not allowed to control this device.
  15. 15. /etc/sysconfig/static-routesYou can add the following two lines to the file"/etc/sysconfig/static-routes":eth0 net netmask gw net netmask gw
  16. 16. Network Administration ToolThe Network Administration Tool (system-config-network) isan easy way to make changes to the various networkinterface configuration filesPg 159 #system-config-network
  17. 17. 1. Add a network device associated with the physical hardware device.2. Configure the hostname and DNS settings.3. Configure any hosts that cannot be looked up throughDNS.
  18. 18. DHCP configuration1. Backup existing static configuration• First backup existing network configuration file using cp command: # cp /etc/sysconfig/network-scripts/ifcfg-eth0 /root/ifcfg-eth0.bak2. Configuring a DHCP Client:• Setting up a Linux for dhcp can be done by editing file using a text editor such as vi: # vi /etc/sysconfig/network-scripts/ifcfg-eth0
  19. 19. DHCP configuration• Following is sample static configuration: DEVICE=eth0 BOOTPROTO=static HWADDR=00:19:D1:2A:BA:A8 IPADDR= NETMASK= ONBOOT=yes
  20. 20. DHCP configuration3. Replace static configuration with DHCP: DEVICE=eth0 BOOTPROTO=dhcp HWADDR=00:19:D1:2A:BA:A8 ONBOOT=yes4. Save and close the file. Just restart network service: # /etc/init.d/network restart (in ubuntu the service is called networking) Please note that you need a configuration file for each device that you want to configure to use DHCP.