LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Internet Sharing: Redhat9 and Windows XP Pro (https://www.linuxquestions.org/questions/linux-networking-3/internet-sharing-redhat9-and-windows-xp-pro-208647/)

Cloud78 07-23-2004 05:25 AM

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

maxut 07-23-2004 10:01 AM

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

Cloud78 07-23-2004 10:16 AM

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

maxut 07-23-2004 10:30 AM

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. :D


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

Cloud78 07-23-2004 02:07 PM

Yes I was aware of that part so when I created before I did change to ppp0...

thank you

Cloud78 07-24-2004 12:16 AM

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

maxut 07-24-2004 01:32 AM

welcome to liux world :D

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.

Cloud78 07-24-2004 10:25 AM

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

reihat 07-24-2004 11:12 AM

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?

maxut 07-24-2004 11:24 AM

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.

reihat 07-24-2004 11:51 AM

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

maxut 07-24-2004 12:08 PM

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) :D

mermxx 07-24-2004 03:40 PM

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)

reihat 07-24-2004 05:43 PM

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) :D

:D 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.

WMD 07-24-2004 06:18 PM

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.


All times are GMT -5. The time now is 12:33 PM.