Sponsored Content
Operating Systems Linux Red Hat How to LINUX machine as a router. Post 302595528 by saqlain.bashir on Friday 3rd of February 2012 04:05:48 PM
Old 02-03-2012
hhhhmmmm....
so i can understand that we can configure our host machine better then virtual machine.
& " I would like to say that there is nothing difference b/w CentOS, Red Hat & Fedora regarding file locations, commands,configuration etc... But I can assume some of the minor difference, Which I have not see yet"

So its decided that I am going to configure my host machine's second NIC "eth1" as a router & I'll post all the configurations & hope you'll guide me...
Thanks allot ,,,,....

---------- Post updated 02-04-12 at 02:05 AM ---------- Previous update was 02-03-12 at 09:03 PM ----------

Yes I done it...
I configure my Linux machine to behave like a router.
Configurations are as follow!

First we need to enable packet forwarding on the kernel level. So append the following two lines in /etc/sysctl.conf file:
Code:
# vim /etc/sysctl.conf

Code:
# Controls IP packet forwarding
net.ipv4.ip_forward = 1

Now Configure your interface with the following parameters, In my case the interface was eth1 you may follow yours, So I apply this command to make changes/to set the parameters:
Code:
# vim /etc/sysconfig/network-scripts/ifcfg-eth1

Parameters for the eth1 file should like this:
Code:
DEVICE=eth1
BOOTPROTO=none
IPADDR=10.3.20.1
IPV6INIT=no
ONBOOT=yes
NAME=eth1
NETMASK=255.255.255.0
HWADDR=00:04:75:EB:D0:A3
TYPE=Ethernet
PREFIX=24
GATEWAY=10.3.20.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
UUID=9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04

Now add the route followed by the command:
Code:
# route add -net 10.3.20.0 netmask 255.255.255.0 gw 10.3.20.1 dev eth1

To define the routing for the 10.3.20.0 network on the 10.3.20.1 interface (eth1) open the file:
Code:
# vim /etc/sysconfig/network-scripts/route-eth1

IN this file append the following line:
Code:
10.3.20.0/24 via 10.3.20.1

Now restart the network service with the following command:
Code:
# service network restart

Check the new route with the following command:
Code:
# route -n

In my case the outputs was like this:
Code:
[root@rash ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.3.20.0       0.0.0.0         255.255.255.0   U     1      0        0 eth1
192.168.15.0    0.0.0.0         255.255.255.0   U     1      0        0 eth0
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
0.0.0.0         192.168.15.1    0.0.0.0         UG    0      0        0 eth0
You have new mail in /var/spool/mail/root

You may easily find the new route in these information.
Conguratulations with this guide you have configured your Linux machine to act as a router.Smilie
 

3 More Discussions You Might Find Interesting

1. IP Networking

Linux Router?

I am trying to set up a linux box as a router, but I am a little confused on how to do this. I am using Red Hat 9.0 on a machine that has 2 nic cards. Also, I am using a DSL pppoe connection. I have installed rp-pppoe and I am connected to the internet via the pseudo pppoe interface. I have... (1 Reply)
Discussion started by: cstovall
1 Replies

2. Shell Programming and Scripting

SSH into a linux machine from a windows machine

I basically want to login into different linux machines( on the same network) from a windows machine. I know i can use ssh <machine name>. But i want to automate this process. I dont want to enter the username and password. Is there any way to do it. Can i make some sort of a batch script for it. (4 Replies)
Discussion started by: lassimanji
4 Replies

3. Shell Programming and Scripting

shell script to copy files frm a linux machine to a windows machine using SCP

I need a shell script to copy files frm a linux machine to a windows machine using SCP. The files keeps changing day-to-day. I have to copy the latest file to the windows machine frm the linux machine. for example :In Linux, On July 20, the file name will be 20.txt and it should be copied to... (3 Replies)
Discussion started by: nithin6034
3 Replies
All times are GMT -4. The time now is 06:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy