|
Home Office Networking: RedHat Linux 7.2/7.3 using Static IP
|
|
| Summary |
This is my personal experience of setting my home network using RedHat 7.2 as gateway.
I write down all the steps and some look outs to remind myself and the others. There is no guarantee these steps will fit you.
Please feel free to try them.
|
|
| Scenario |
Want to connect a home network consists of two computers, one RH 7.2 and one Windows 2000 to share a
single internet connection. A pc is setup with RH7.2 as gateway and firewall to perform ip masquerading.
My ISP is Charter Pipeline cable modem. I was provided with DHCP.
|
| Setup Layout |
Machine 1 is RH7.2 with server installation, which will be used as server and gateway with ip masquerading. Two network cards on this machine.
Machine 2 is Windows 2000, this is the second client. One network card on this machine.
|
|
| Setup Server for Internal network |
Two ethernet cards are installed in the Machine A, eth0 and eth1. eth0 is connected to Charter Pipeline
cable modem. eth1 is connected to a hub. I don't elaborate OS installation in this text. Since eth0 is connected to dhcp server from Charter,
not much story to tell on eth0. I will concentrate on eth1. eth1 will be assigned with a non-routable ip address. By convention,
I assign with 192.168.0.1. Here is the complete ifcfg-eth1 file i used in my setting.
Save this file as ifcfg-eth1 at /etc/sysconfig/network-scripts directory.
The configuration file for eth0 is very simple. It looks like following.
Then restart network by running command /etc/rc.d/init.d/network restart
You should see both eth0 and eth1 start up correctly.
|
|
| Setup Windows 2000 machine |
One windows 2000 machine, I want to set it up as 192.168.0.2. So go to start->settings->Network and Dial up Connection.
Locate your NIC icon Local Area Connection. Right click at the icon and choose Properties.
Highlight Internet Protocol [TCP/IP] then click at Properties. Check Use the following IP address. Enter
the following information.
To determine XXX.XXX.XXX.XXX and YYY.YYY.YYY.YYY, go to linux server (your gateway machine) and view the file resolv.conf
located at /etc. You should see several nameserver listed in resolv.conf. Pick the first two nameserver ip addresses
and assign them to Preferred DNS and Alternate DNS. That is all for Windows 2000 machine setup.
Now, you should be able to ping the server from windows. Type ping 192.168.0.1, then ping your Windows 2000 from
the Linux server. Type ping 192.168.0.2. Both Linux server and Windows 2000 client should ping fine.
Now if you ping a outside IP address or ping a URL from Windows 2000 machine, it will not work.
|
|
| Setup Server IP Masquerading |
Don't be scared by big word like Masquerading. I was and I am not. To setup IP masquerading on Linux machine, create a script with
the following content and save it somewhere on Linux machine. I call this file myscript. This is the script to enable IP Masquerading.
Make myscript executable by chmod 755 myscript.
Now you can exectue myscript by typing ./myscript. After you execute this script, your IP masquerading should work. You can ping www.yahoo.com directly from your
Windows 2000 machine and you will see replies. To automate the script on every boot up, copy the script to
/etc/rc.d. Add this line /etc/rc.d/myscript to the bottom of rc.local.
That is all folks.
|
|
| Debugging notes |
- Network cards on linux server must be started before the IP Masquerading script is run.
If you restart your network, content of /proc/sys/net/ipv4/ip_forward will be reset to 0.
- If Windows 2000 machine can ping Yahoo's IP address but not Yahoo URL(www.yahoo.com),
most likely you forget to set your DNS on Windows 2000 machine.
- If you cannot ping outsite IP from Windows 2000 machine,
most likely your IP Masquerading on Linux server does not work properly.
Try to flush all the chains with command "iptables -F INPUT", "iptables -F FORWARD" and "iptables -F OUTPUT".
Then rerun your IP Masquerading script again.
- Always check the content of /proc/sys/net/ipv4/ip_forward.
If it is 0, it means no forwarding. You need to change it to 1.
- I don't have to do route add in my setting as shown in the yolinux tutorial. As long as it works, I am happy.
|
|
| Conclusion |
I found myself restart the network and rerun the IP Masquerading script on Linux machine many times. However, i don't reboot
my Linux machine very often. Rerun script, restart network cards, check /proc/sys/net/ipv4/ip_forward content, pinging from Windows 2000
to other IP and URL are the tasks you will do many times until you get the thing right. Hope this help.
|
|
| Extra |
The following code is another version of simple firewall rule you can
use in IP Masquerading. Copy and save this file and add it to your init script. I obtain this file from somewhere else.
Name the file "rc.firewall" and save at /etc/rc.d/rc.firewall. To enable auto execution of this script at boot time, add
this file entry in "/etc/rc.d/rc.local".
|