LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-23-2004, 05:25 AM   #1
Cloud78
LQ Newbie
 
Registered: Jul 2004
Posts: 5

Rep: Reputation: 0
Question Internet Sharing: Redhat9 and Windows XP Pro


I have been trying to get my other windows xp pro connect to my RedHat 9.0 box, so far I can ping, and I don't use dhcp so I configure the ip
, and I use the crossover cable and 2 Network Card to connect them
RedHat : IP 192.168.0.1
Netmask: 255.255.255.0

Windows XP: IP 192.168.0.2
Netmask: 255.255.255.0
DNS Server: 192.168.0.1
Gateway: 192.168.0.1

an I am on dial-up, and I did try to follow this guide (I got this from other site)

Quote:
This is a how-to about sharing the internet via a linux box to the rest of your internal network.

In windows this is know as ICS (Internet Connection Sharing).
In linux it is called NAT (Network Address Translation).

1. On the linux box (that is directly connected to the internet, and is supposed to do the internet sharing), start a terminal. Run the command su and then type the root password to become root.

2. Open the file /etc/rc.d/rc.local in your favorite text editor and add this on a new line at the bottom
/etc/rc.d/rc.ipmasq and save the file.

3. Then, create a new file called rc.ipmasq in the /etc/rc.d/ directory and open this file in a text editor and add these lines



#!/bin/sh

IPTABLES=/sbin/iptables

#All The lines below are NAT routing

# flush any old rules
$IPTABLES -F -t nat

# turn on NAT (IP masquerading for outgoing packets)
$IPTABLES -A POSTROUTING -t nat -o eth0 -j MASQUERADE

# enable IP forwarding (of incoming packets)
echo 1 > /proc/sys/net/ipv4/ip_forward



Save this file.

This script assumes that eth0 is the ethernet adaptor connected to the internet (say, thru a DSL/cable modem). Change it depending on your configuration (eth1, eth2 and so on). If the connection to the internet is not thru an ethernet device (as in the case of ordinary dialup or USB modem), you have to use ppp0 (or ppp1, ppp2 and so on).
The network connections to the internet and intranet should already be up (how to do that is outside the scope of this document).

4. Make this script file executable by running chmod 755 /etc/rc.d/rc.ipmasq

5. Then run the command /etc/rc.d/rc.ipmasq to enable the internet sharing.

6. Now you can stop being root by running exit

The above script will work after the following have been already done:

Set up the network on all the computers in the LAN. Make sure every computer can be reached from another computer by "ping".
On each client computer, set the gateway to the internal IP address of the linux computer that is connected directly to the internet. Under DNS put in the primary and/or secondary DNS IP addresses of your ISP (Internet Service Provider).


but still no luck, Did I miss something?

thank you
 
Old 07-23-2004, 10:01 AM   #2
maxut
Senior Member
 
Registered: May 2003
Location: istanbul
Distribution: debian - redhat - others
Posts: 1,188

Rep: Reputation: 50
your script flushes nat table only. if there are some rules that can block forwarding or input from LAN, your nat rule cant work.
u can try to generate a script from www.iptables-scrpits.dk and try it.

u must also run named in linux if u assing linux ip as DNS in windowz's network configuration. other way u can use ISP nameservers instead of 192.168.0.1
 
Old 07-23-2004, 10:16 AM   #3
Cloud78
LQ Newbie
 
Registered: Jul 2004
Posts: 5

Original Poster
Rep: Reputation: 0
I tried the link but it seems it is not working..
and I will try to named in linux and I will tell what will happen..

thank you
 
Old 07-23-2004, 10:30 AM   #4
maxut
Senior Member
 
Registered: May 2003
Location: istanbul
Distribution: debian - redhat - others
Posts: 1,188

Rep: Reputation: 50
Re: Internet Sharing: Redhat9 and Windows XP Pro

Quote:
Originally posted by Cloud78


an I am on dial-up, and I did try to follow this guide (I got this from other site)
im so sorry! i missed this line about dial up.


so u must use ppp0 instead of eth0 as output interface:
$IPTABLES -A POSTROUTING -t nat -o ppp0 -j MASQUERADE

Last edited by maxut; 07-23-2004 at 10:32 AM.
 
Old 07-23-2004, 02:07 PM   #5
Cloud78
LQ Newbie
 
Registered: Jul 2004
Posts: 5

Original Poster
Rep: Reputation: 0
Yes I was aware of that part so when I created before I did change to ppp0...

thank you
 
Old 07-24-2004, 12:16 AM   #6
Cloud78
LQ Newbie
 
Registered: Jul 2004
Posts: 5

Original Poster
Rep: Reputation: 0
Hi I just tried to run the named on my RedHat Box but still no luck, Do I need too change somthing on the named.conf.
and is there any website that could guide me step by step on doing this? because I am newbie, just started learning about linux in school

thank you
 
Old 07-24-2004, 01:32 AM   #7
maxut
Senior Member
 
Registered: May 2003
Location: istanbul
Distribution: debian - redhat - others
Posts: 1,188

Rep: Reputation: 50
welcome to liux world

first make sure about iptables rules. connect internet and when u r root, type the followings and post the outputs here:
#/sbin/iptables -nvL
#/sbin/iptables -t nat -nvL
#/sbin/ifconfig
#/sbin/route -n

it is enough to start named, it will work as a caching only nameserver. also u can prefer forwarding dns queries. it can reduce query time.

add the following necessary lines in named.conf
forward first ;
forwarders { ISP_nameserver_ip };

also u can use forward only instead of forward first

read the man page of named.conf
#man named.conf

but u dont have to run named. if u configure windows to use your ISP nameserver, so u wont need to run named in linux. it is up to u.
 
Old 07-24-2004, 10:25 AM   #8
Cloud78
LQ Newbie
 
Registered: Jul 2004
Posts: 5

Original Poster
Rep: Reputation: 0
oke here are the outputs:
/sbin/iptables -nvL

Chain INPUT (policy ACCEPT 177 packets, 108K bytes)
pkts bytes target prot opt in out source destination

6255 524K RH-Lokkit-0-50-INPUT all -- * * 0.0.0.0/0 0
.0.0.0/0

Chain FORWARD (policy ACCEPT 37 packets, 3987 bytes)
pkts bytes target prot opt in out source destination

43 4275 RH-Lokkit-0-50-INPUT all -- * * 0.0.0.0/0 0
.0.0.0/0

Chain OUTPUT (policy ACCEPT 6274 packets, 444K bytes)
pkts bytes target prot opt in out source destination


Chain RH-Lokkit-0-50-INPUT (2 references)
pkts bytes target prot opt in out source destination

5 1281 ACCEPT udp -- * * 203.109.250.50 0.0.0.0/0
udp spt:53 dpts:1025:65535
0 0 ACCEPT udp -- * * 203.109.128.2 0.0.0.0/0
udp spt:53 dpts:1025:65535
0 0 ACCEPT udp -- eth0 * 0.0.0.0/0 0.0.0.0/0
udp spts:67:68 dpts:67:68
0 0 ACCEPT udp -- eth1 * 0.0.0.0/0 0.0.0.0/0
udp spts:67:68 dpts:67:68
5979 408K ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0

43 2064 REJECT tcp -- * * 0.0.0.0/0 0.0.0.0/0
tcp dpts:0:1023 flags:0x16/0x02 reject-with icmp-port-unreachable
0 0 REJECT tcp -- * * 0.0.0.0/0 0.0.0.0/0
tcp dpt:2049 flags:0x16/0x02 reject-with icmp-port-unreachable
57 4146 REJECT udp -- * * 0.0.0.0/0 0.0.0.0/0
udp dpts:0:1023 reject-with icmp-port-unreachable
0 0 REJECT udp -- * * 0.0.0.0/0 0.0.0.0/0
udp dpt:2049 reject-with icmp-port-unreachable
0 0 REJECT tcp -- * * 0.0.0.0/0 0.0.0.0/0
tcp dpts:6000:6009 flags:0x16/0x02 reject-with icmp-port-unreachable
0 0 REJECT tcp -- * * 0.0.0.0/0 0.0.0.0/0
tcp dpt:7100 flags:0x16/0x02 reject-with icmp-port-unreachable


[root@localhost root]# /sbin/iptables -t nat -nvL
Chain PREROUTING (policy ACCEPT 169 packets, 15206 bytes)
pkts bytes target prot opt in out source destination


Chain POSTROUTING (policy ACCEPT 201 packets, 12132 bytes)
pkts bytes target prot opt in out source destination

18 1086 MASQUERADE all -- * ppp0 0.0.0.0/0 0.0.0.0/0


Chain OUTPUT (policy ACCEPT 252 packets, 15290 bytes)
pkts bytes target prot opt in out source destination


[root@localhost root]# /sbin/ifconfig
eth0 Link encap:Ethernet HWaddr 00:40:33:94:59:7D
inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:210 errors:0 dropped:0 overruns:0 frame:0
TX packets:115 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:25694 (25.0 Kb) TX bytes:15088 (14.7 Kb)
Interrupt:5 Base address:0xa400

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:7765 errors:0 dropped:0 overruns:0 frame:0
TX packets:7765 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:530378 (517.9 Kb) TX bytes:530378 (517.9 Kb)

ppp0 Link encap:Point-to-Point Protocol
inet addr:203.173.164.234 P-t-P:203.109.128.22 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1524 Metric:1
RX packets:307 errors:1 dropped:0 overruns:0 frame:0
TX packets:382 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:139749 (136.4 Kb) TX bytes:50105 (48.9 Kb)



[root@localhost root]# /sbin/route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
203.109.128.22 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 lo
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 203.109.128.22 0.0.0.0 UG 0 0 0 ppp0


and as for the dns for my isp, the isp told me to leave it blank/automatic.

thank you
 
Old 07-24-2004, 11:12 AM   #9
reihat
LQ Newbie
 
Registered: May 2004
Location: Asia
Distribution: Linux Red Hat 9
Posts: 16

Rep: Reputation: 0
hey guys,

i have this little problem that i can't seem to figure out.

I'm trying to network my desktop (windows XP) to my laptop (RH9) on a cross-over cable connection. yeah i know it should be the other way but i want internet connection to be shared (AOL works fine with windows).

my problem is i can't even ping each other. i just configured windows ip to 192.168.100.11 and netmask to 255.255.255.0

in my linux box i configured eth0 to IP: 192.168.100.12 subnetmask: 255.255.255.0 and gateway: 192.168.100.11

how come i can't ping?
 
Old 07-24-2004, 11:24 AM   #10
maxut
Senior Member
 
Registered: May 2003
Location: istanbul
Distribution: debian - redhat - others
Posts: 1,188

Rep: Reputation: 50
everything looks ok. now open /etc/rc.d/rc.local file with your favourite text editor. if there are some lines that u added b4 in this file remove them first then copy the following and past it into file. and save it.

/sbin/iptables -t nat -F POSTROUTING
/sbin/iptables -t nat -F PREROUTING
/sbin/iptables -t nat -F OUTPUT
/sbin/iptables -F
/sbin/iptables -P INPUT DROP
/sbin/iptables -P FORWARD DROP
/sbin/iptables -P OUTPUT ACCEPT
/sbin/iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE
/sbin/iptables -A FORWARD -j ACCEPT -i eth0 -s 192.168.0.0/24
/sbin/iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward

after that, restart your computer. and after reboot it must work.
 
Old 07-24-2004, 11:51 AM   #11
reihat
LQ Newbie
 
Registered: May 2004
Location: Asia
Distribution: Linux Red Hat 9
Posts: 16

Rep: Reputation: 0
duh... after rebooting, i'm stucked at the login window after entering the root password

it's 1:00 here in manila, maybe i need a rest 0_o
 
Old 07-24-2004, 12:08 PM   #12
maxut
Senior Member
 
Registered: May 2003
Location: istanbul
Distribution: debian - redhat - others
Posts: 1,188

Rep: Reputation: 50
reihat, sorry that post was for Cloud78. i think when i was typing my input u sent your post.

hmmm the ping trouble:
1- maybe NIC or cable doesnt work. check the ligths of NICs. if its ok:
2- firewall can cause this. check firewall at both side.
3- there can be other reasons i couldnt remember (know)
 
Old 07-24-2004, 03:40 PM   #13
mermxx
Member
 
Registered: Apr 2004
Location: Wales
Distribution: rh9, winxp
Posts: 411

Rep: Reputation: 30
reihat have u tried enabling ics (internet connection sharing) with ur xp machine in which case this will allocate the ip address of that machine which u can then add into ur linux connection settings which makes life a whole lot easier :-) U obviously have the right idea with addresses and as maxut says also check ur firewall (especially on xp setting it to medium or which ever it is to allow networking to local addresses)
 
Old 07-24-2004, 05:43 PM   #14
reihat
LQ Newbie
 
Registered: May 2004
Location: Asia
Distribution: Linux Red Hat 9
Posts: 16

Rep: Reputation: 0
Quote:
Originally posted by maxut
reihat, sorry that post was for Cloud78. i think when i was typing my input u sent your post.

hmmm the ping trouble:
1- maybe NIC or cable doesnt work. check the ligths of NICs. if its ok:
2- firewall can cause this. check firewall at both side.
3- there can be other reasons i couldnt remember (know)
i guess i was really that sleepy last night. just woke up and took linux rescue as my breakfast.


i am using wingate for internet sharing because for some reason i can't share internet when using windoze to windoze or it's just me who's too dumb for this network thingie.

anyway i'll try to uninstall wingate and will enable ICS for this.

by the my specs are:
AMD Athlon 64 3400+
Gigabyte K8NSNXP (this has a dual LAN on board - i dunno if this has something to do with the trouble I am experiencing)

i will post results later.
 
Old 07-24-2004, 06:18 PM   #15
WMD
Member
 
Registered: Jul 2004
Location: Florida
Distribution: Slackware, Debian
Posts: 484

Rep: Reputation: 30
Quote:
Originally posted by reihat
i am using wingate for internet sharing because for some reason i can't share internet when using windoze to windoze or it's just me who's too dumb for this network thingie.
Wingate is a proxy server, which requires cofiguring your web browser. ICS is simpler.

And for Cloud78....Try using Webmin to configure NAT. It's easier than using just the scripts.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Internet sharing help in suse 9.3 pro Be.Gurmeet.Be SUSE / openSUSE 1 07-23-2005 08:08 AM
Internet Connection Sharing with Redhat9 Ogi Linux - Networking 5 07-16-2004 05:01 PM
Internet Connection Sharing through Windows 2000 Pro atheist Red Hat 7 10-18-2003 08:25 PM
RedHat9 sharing internet connection with XP silverstormer Linux - Networking 10 09-11-2003 10:17 AM
help with redhat9.0 internet sharing icecube76 Linux - Networking 1 06-29-2003 06:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration