Network configuration

Post on 05-Dec-2014

1.401 views 1 download

Tags:

description

This ppt allows you to configure network on linux redhat

Transcript of Network configuration

Linux RedhatNetwork Configuration

ifconfig

Ifconfig or ifconfig -a

#Ifconfig eth0 up

==#service network restart

#ifconfig eth0 192.168.10.12 netmask 255.255.255.0 broadcast 192.168.10.255 up

#Ifconfig eth0 down

To configure a static IP:

# route add default gw {IP-ADDRESS} {INTERFACE-NAME}#route add default gw 192.168.1.254 eth0

Default route(Default Gateway)

#ip route show this is a command to show you the default

gateway and the ip You can add static route using following command:#ip route add {NETWORK} via {IP} dev {DEVICE}For example network 192.168.55.0/24 available via 192.168.1.254:# ip route add 192.168.55.0/24 via 192.168.1.254 dev eth1

Alternatively, you can use old good route command:# route add -net 192.168.55.0 netmask 255.255.255.0 gw 192.168.1.254 dev eth1

static route

Network Configuration Files

/etc/hostsThe main purpose of this file is to resolve hostnames that cannot be resolved any other way. It can also be used to resolve hostnames on small networks with 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 configuration script. Each of these files provide information specific to a particular network interface.

/etc/sysconfig/network

The /etc/sysconfig/network file is used to specify information about the desired network configuration. The following values may be used:

• NETWORKING=<value>, where <value> is one of the following boolean values: yes — Networking should be configured. no — Networking should not be configured.

• HOSTNAME=<value>, where <value> should be the Fully Qualified Domain Name (FQDN), such as hostname.expample.com, but can be whatever hostname is necessary.

• GATEWAY=<value>, where <value> is the IP address of the network's gateway.

/etc/sysconfig/network

Static 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.

NETWORKING=yes HOSTNAME=my-hostname - Hostname is defined here and by command hostname

OR for DHCP client configuration:

The following is a sample ifcfg-eth0 file for a system using a FIXED IP address:

DEVICE=eth0BOOTPROTO=noneONBOOT=yesNETWORK=10.0.1.0NETMASK=255.255.255.0IPADDR=10.0.1.27USERCTL=no

Example, using DHCP server:

# Intel Corporation 82540EM Gigabit Ethernet ControllerDEVICE=eth0BOOTPROTO=dhcpHWADDR=08:00:27:FF:FB:FEONBOOT=yes

/etc/sysconfig/network-scripts/ifcfg-<interface-name>

Below is a listing of the configurable parameters in an Ethernet interface configuration file:/etc/sysconfig/network-scripts/ifcfg-<interface-name>

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 for dynamically-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.

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 the formAA:BB:CC:DD:EE:FF. This directive must be used in machines containing more than one NIC to ensure that the interfaces are assigned the correct device names regardless of the configured load order for each NIC's module. 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.

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.

You can add the following two lines to the file "/etc/sysconfig/static-routes":

eth0 net 192.168.2.0 netmask 255.255.255.0 gw 192.168.2.1eth1 net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.2

/etc/sysconfig/static-routes

The Network Administration Tool (system-config-network) is an easy way to make changes to the various network interface configuration files

Pg 159

Network Administration Tool

#system-config-network

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 through DNS.

DHCP configuration

1. Backup existing static configuration• First backup existing network configuration file

using cp command:# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /root/ifcfg-eth0.bak

2. 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

DHCP configuration

• Following is sample static configuration:DEVICE=eth0BOOTPROTO=staticHWADDR=00:19:D1:2A:BA:A8IPADDR=10.10.29.66NETMASK=255.255.255.192ONBOOT=yes

DHCP configuration3. Replace static configuration with DHCP:

DEVICE=eth0BOOTPROTO=dhcpHWADDR=00:19:D1:2A:BA:A8ONBOOT=yes

4. 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.