How to create very simple Linux Gateway
Some administrator doesn’t realize that to have a pc gateway is very usefull.
They can manage the connection if they have 2 or more connections to be load balanced or just automatic backup connection.
The principal of a gateway is every packet and requested through the ethernet card are will be forwarded.
Check your ip address first:
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:8D:63:A1:A4
inet addr:192.168.1.5 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:383259 errors:0 dropped:0 overruns:0 frame:0
TX packets:376249 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:52177377 (49.7 MiB) TX bytes:53007914 (50.5 MiB)
Interrupt:16 Base address:0xa000
To enable forwarded packet :
# echo 1 > /proc/sys/net/ipv4/ip_forward
This means every ipv4 packet will be forwarded.
The question is forwarded to where ?
You can manage these by creating route.
# route add default gw 192.168.1.10
192.168.1.10 is internet gateway given by your modem, adsl or dial-up modem.
Test it by changing the gateway into 192.168.1.5 on one of the computer on your network( Pc A).
All requested by PC A will be go through 192.168.1.5
And of course you have to configure the firewall about this.
Meanwhile I turn off the firewall first. Because I want to do more about this gateway.
That is for now, next I will share how to handle 2 or more different connection with only 1 single gateway without creating DNS and others.