LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   internet sharing problem (https://www.linuxquestions.org/questions/linux-networking-3/internet-sharing-problem-710969/)

bharatlalgupta 03-12-2009 03:19 AM

internet sharing problem
 
Hi
i'm using RHEL5 linux ,
i have a broadband connection on window but now i want use this on linux
and i want to share this internet connection with MS Window and linux Opreating system.....
so plz, tell me procedure of configuration a internet connection for local PC and sharing it..
on window and linux...

kirukan 03-12-2009 05:08 AM

your post is little bit unclear whether you are asking about physical connection of each PCs or network configuration

network configuration for linux (this is static ip configuration method)
#vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=172.16.8.154
NETMASK=255.255.0.0
GATEWAY=172.16.100.25

#vi /etc/resolv.conf
nameserver 172.16.121.50
nameserver 172.16.121.60
change ips according to your network
#service network restart ;after modify the ips restart the network services

# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.16.100.25 0.0.0.0 UG 0 0 0 eth0
makesure your default gateway

#ping yahoo.com
64 bytes from w2.rc.vip.re4.yahoo.com (206.190.60.37): icmp_seq=1 ttl=49 time=309 ms
64 bytes from w2.rc.vip.re4.yahoo.com (206.190.60.37): icmp_seq=2 ttl=49 time=309 ms
if this ping replay that means you have sucessfully configured network

if your broadband router enabled dhcp service(most of the routers having dhcp service) ,it will supply ip for your pcs

ddaemonunics 03-12-2009 05:31 AM

if that's the case

provider---------linux-box(as gateway)----------client1 (windows)


the I suppose your linux-box has 2 network interfaces
eth0 - provider IP netmask gateway and name server
eth1- 192.168.0.1 255.255.255.0
default gateway is that from your provider



enable ip_forward in /etc/sysctl.conf or echo "1" > /proc/sys/net/ipv4/ip_forward

in iptables enable masquerade
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

on client
IP 192.168.0.7 netmask 255.255.255.0 gateway 192.168.0.1 nameserver provider

test conectivity from client to linux-box (ping 192.168.0.1)
test conectivity from client to provider gateway(ping provider gateway)

Zeusz3 03-28-2009 05:40 PM

hello, am trying to do a similart setup but there is somethings that am not doing right and it ain't working
ISP---->box1------>box2

box1 runs debian etch and has the following setup
eth0 is connected to box2 (ip 192.168.0.1)
eth1 is connected to the internet (DHCP) (internet works fine, but i can't ping box2 neither can box2 ping box1)
here are the results of
1- route

Kernel IP routing table
Destination------Gateway---------Genmask---------Flags-Metric-Ref---Use Iface
192.168.0.0------0.0.0.0--------255.255.255.0----U-----0------0-------0-eth0
147.102.132.0---0.0.0.0---------255.255.252.0----U-----0------0-------0-eth1
0.0.0.0--------147.102.132.200--0.0.0.0----------UG----0------0-------0-eth1
-------------------------------------------------------------------------------

2- ping -c 2 192.168.0.2

PING 192.168.0.2 (192.168.0.2) 56(84) bytes of data.
From 192.168.0.1 icmp_seq=1 Destination Host Unreachable
From 192.168.0.1 icmp_seq=2 Destination Host Unreachable

--- 192.168.0.2 ping statistics ---
2 packets transmitted, 0 received, +2 errors, 100% packet loss, time 1009ms
, pipe 2
-------------------------------------------------------------------------------


3- i have the following in my /etc/network/if-up.d saved under the name 00-firewall.sh

iTH=/usr/sbin:/sbin:/bin:/usr/bin

#
# delete all existing rules.
#
iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -X

# Always accept loopback traffic
iptables -A INPUT -i lo -j ACCEPT


# Allow established connections, and those not coming from the outside
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -m state --state NEW -i ! eth1 -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT

# Allow outgoing connections from the LAN side.
iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT

# Masquerade.
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE

# Don't forward from the outside to the inside.
iptables -A FORWARD -i eth1 -o eth1 -j REJECT

# Enable routing.
echo 1 > /proc/sys/net/ipv4/ip_forward
--------------------------------------------------------------------------------------

4- ifconfig

eth0 Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:xx
inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::20f:b5ff:fef5:ea42/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:79 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:9860 (9.6 KiB)
Interrupt:11 Base address:0x6000

eth1 Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:xx
inet addr:147.102.132.xx Bcast:147.102.135.255 Mask:255.255.252.0
inet6 addr: fe80::21a:4dff:fe5a:d73d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:30614 errors:0 dropped:0 overruns:0 frame:0
TX packets:6160 errors:0 dropped:0 overruns:0 carrier:0
collisions:1230 txqueuelen:1000
RX bytes:5032762 (4.7 MiB) TX bytes:846979 (827.1 KiB)
Interrupt:10 Base address:0xc800

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:26 errors:0 dropped:0 overruns:0 frame:0
TX packets:26 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2296 (2.2 KiB) TX bytes:2296 (2.2 KiB)

===============================================================================

box2 also uses debian etch and has the following setup
eth0 connected to box1 (ip 192.168.0.2)
results of:

1- route
Kernel IP routing table
Destination - Gateway - Genmask - Flags -Metric- Ref - Use Iface
192.168.0.0 - 0.0.0.0 - 255.255.255.0 - U - 0 - 0 - 0-eth0
default - 192.168.0.1 - 0.0.0.0 - UG - 0 - 0 - 0-eth0
--------------------------------------------------------------------------------------------

2- ping -c 2 192.168.0.1

PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
From 192.168.0.2 icmp_seq=1 Destination Host Unreachable
From 192.168.0.2 icmp_seq=2 Destination Host Unreachable

--- 192.168.0.1 ping statistics ---
2 packets transmitted, 0 received, +2 errors, 100% packet loss, time 1000ms
, pipe 2
------------------------------------------------------------------------------------------

3- no iptables running



how can i share the internet connection on box1 with box2?


All times are GMT -5. The time now is 07:19 AM.