LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 05-12-2012, 11:30 PM   #1
paruhang
Member
 
Registered: Aug 2011
Location: /home
Posts: 96

Rep: Reputation: Disabled
network problem eth0 and eth1


hi everybody,
iam new to linux and iam using 32 bit centos 6.2 on my desktop.

1) my isp give me public ip x.x.x.x in wireless device.
2) dhcp was enable in that device 10.10.10.100-200
3) default gateway is 10.10.10.245
4) i have eth0 and eth1 on my desktop.
5) i have 8 port switch

what i want to do is:

1) in eth0 i want to give static ip 10.10.10.101 in desktop.
2) from eth1 i want to connect to switch.
3) from switch i want to connect to other computer and want access internet.

i have explain my conditons above and if possibl want to learn from command line. iam new to linux, can anybody help me to solve my above problem. Any kinds of ideas, guidelines and suggestions are welcome and i'll be greatful.
THANK YOU IN ADVANCEE.

Last edited by paruhang; 05-12-2012 at 11:33 PM.
 
Old 05-13-2012, 12:25 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
What is the netmask? 255.255.255.0? What is the IP of the wireless interface?

You could subnet the network and enable forwarding.
For example, if the wireless device is 10.10.10.100 and another device is 10.10.10.130, and you used a netmask of 255.255.255.128, then your computer could route between the 10.10.10.0/25 and 10.10.10.128/25 networks.

This presumes that the wireless modem also contains a NAT router.

I did this once to give my desktop wireless access by connecting through my laptop.
I found out that I needed to load the tcp_conntrack module before forwarding would work. Not sure why. It is called nf_conntrack now and is probably loaded by default.

I don't use centos. I think you can enable forwarding in it's gui network device configuration tool.
If you have a /etc/sysctl.conf file, you can also edit a line to enable it on boot. Change net.ipv4.ip_foward from 0 to 1:
Code:
# net.ipv6.conf.all.disable_ipv6 = 1
# net.ipv6.conf.all.disable_ipv6 = 1
kernel.sysrq = 1
net.ipv4.ip_forward = 0
net.ipv4.tcp_syncookies = 1
net.ipv6.conf.all.forwarding = 0
 
Old 05-13-2012, 12:57 AM   #3
paruhang
Member
 
Registered: Aug 2011
Location: /home
Posts: 96

Original Poster
Rep: Reputation: Disabled
thank you,
jschiwal for your quick reply. when i add manually my ip address, netmask was automatically assign 8, gateway and dns servers. it works on my desktop.

Code:
address        netmask        gateway
10.10.10.101   8              10.10.10.254

dns servers 10.10.10.254
may be my subnet 255.0.0.0 and ip address of wireless interface be 10.10.10.254 if iam not wrong. do i need the wireless router password and change the configuration in wireless router..?

i have found a file /etc/sysctl.conf

i was confused, do i have to add
Code:
kernel.sysrq = 1
net.ipv4.ip_forward = 0
net.ipv4.tcp_syncookies = 1
net.ipv6.conf.all.forwarding = 0
in /etc/sysctl.conf

what above code does actually do it enables ipv4 or ipv6


but i was not able to cat ~/bin/man2kindleDX this file. error occurs no shuch file or directory.

what will be the next steps.
 
Old 05-16-2012, 01:21 AM   #4
NM04
Member
 
Registered: Jan 2011
Distribution: Back Track,Fedora,centos
Posts: 240

Rep: Reputation: 14
paruhang,
you dont have to add, those lines should be there in the etc/sysctl.conf file, all you have to do is change the value of "net.ipv4.ip_forward = 0" from '0' to '1'. This will enable the ip forwarding.

Regards,
nm
 
Old 05-22-2012, 12:28 AM   #5
NM04
Member
 
Registered: Jan 2011
Distribution: Back Track,Fedora,centos
Posts: 240

Rep: Reputation: 14
paruhang,
if your problem is solved, MARK THIS THREAD AS SOLVED FROM THE TOP RIGHT CORNER OF THE THREAD.

Regards,
nm
 
Old 05-25-2012, 06:08 AM   #6
paruhang
Member
 
Registered: Aug 2011
Location: /home
Posts: 96

Original Poster
Rep: Reputation: Disabled
thank you for your support NM04,
i have done
Code:
etc/sysctl.conf
net.ipv4.ip_forward = 1
and i have done manually in eth0
Code:
address        netmask        gateway
10.10.10.101   8              10.10.10.254

dns servers 10.10.10.254
it works on my desktop and able to surf internet but when i have done this i was not able to share internet with other computers.

and i have done manually in eth1

Code:
address        netmask        gateway
10.10.10.102   8              10.10.10.101

dns servers 10.10.10.101
eth0 got the direct cable of isp i can surf internet in my desktop. so how can i share internet through switch. i want to connect eth1 and switch. and distribute internet through switch to other computer.
 
Old 05-26-2012, 09:56 PM   #7
KinnowGrower
Member
 
Registered: May 2008
Location: Toronto
Distribution: Centos && Debian
Posts: 347

Rep: Reputation: 34
run the following commands on your desktop

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables --append FORWARD --in-interface eth1 -j ACCEPT

For make these command permanent

iptables-save
or
add these commands on /etc/rc.local
 
Old 05-28-2012, 09:54 AM   #8
paruhang
Member
 
Registered: Aug 2011
Location: /home
Posts: 96

Original Poster
Rep: Reputation: Disabled
thank you, varindersingh.
for your quick reply. i have changed ip of my eth1, i used 192.168.1.1 range ip for my eth1.
i have edited:
Code:
etc/sysctl.conf
net.ipv4.ip_forward = 1
and i have edited iptables too

Code:
# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# iptables --append FORWARD --in-interface eth1 -j ACCEPT
# iptables-save

this is my configuration of my desktop:

for eth0
Code:
address        netmask        gateway
10.10.10.101   255.0.0.0              10.10.10.254

dns servers 10.10.10.254
for eth1
Code:
address        netmask        gateway
192.168.1.1   255.255.255.0   10.10.10.101

dns servers 10.10.10.101

i have windows xp installed in my laptop:

local area network:
Code:
address        netmask        gateway
192.168.1.2   255.255.255.0   192.168.1.1

dns servers 192.168.1.1
when i enable eth0 and eth1:
Code:
eth0      Link encap:Ethernet  HWaddr 00:E2:1C:D1:42:A3  
          inet addr:10.10.10.101  Bcast:10.255.255.255  Mask:255.0.0.0
          inet6 addr: fe80::2e2:1cff:fed1:42a3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3058 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3222 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2719502 (2.5 MiB)  TX bytes:430301 (420.2 KiB)
          Interrupt:21 Base address:0xe000 

eth1      Link encap:Ethernet  HWaddr 00:C0:26:75:B2:D7  
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::2c0:26ff:fe75:b2d7/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:11 errors:0 dropped:0 overruns:0 frame:0
          TX packets:80 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:676 (676.0 b)  TX bytes:11555 (11.2 KiB)
          Interrupt:22 Base address:0xa000


problem from my desktop (10.10.10.101) enabling eth0 and eth1

when i ping yahoo.com from my desktop (10.10.10.101)
Code:
$ ping yahoo.com
PING yahoo.com (209.191.122.70) 56(84) bytes of data.
From 192.168.1.1 icmp_seq=1 Destination Host Unreachable
From 192.168.1.1 icmp_seq=3 Destination Host Unreachable
From 192.168.1.1 icmp_seq=4 Destination Host Unreachable
From 192.168.1.1 icmp_seq=6 Destination Host Unreachable
From 192.168.1.1 icmp_seq=7 Destination Host Unreachable
i was not able to get reply

when i ping 10.10.10.254. 10.10.10.254 is my wireless router given from my isp.
Code:
$ ping 10.10.10.254
PING 10.10.10.254 (10.10.10.254) 56(84) bytes of data.
64 bytes from 10.10.10.254: icmp_seq=1 ttl=64 time=0.311 ms
64 bytes from 10.10.10.254: icmp_seq=2 ttl=64 time=0.279 ms
64 bytes from 10.10.10.254: icmp_seq=3 ttl=64 time=0.285 ms
64 bytes from 10.10.10.254: icmp_seq=4 ttl=64 time=0.309 ms
i get reply


problem from my laptop or 192.168.1.2
Code:
1 ) while ping 192.168.1.1 (eth1 on desktop) from 192.168.1.2 (from laptop) i get reply.
2 ) i was not able to browse internet form my 192.168.1.2 (laptop)
3 ) but when i disable eth1, i was able to browse internet on my desktop but no connection between eth1 (desktop) and my laptop
while disabling eth1:
Code:
eth0      Link encap:Ethernet  HWaddr 00:E2:1C:D1:42:A3  
          inet addr:10.10.10.101  Bcast:10.255.255.255  Mask:255.0.0.0
          inet6 addr: fe80::2e2:1cff:fed1:42a3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2721 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2817 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2285759 (2.1 MiB)  TX bytes:381862 (372.9 KiB)
          Interrupt:21 

eth1      Link encap:Ethernet  HWaddr 00:C0:26:75:B2:D7  
          inet6 addr: fe80::2c0:26ff:fe75:b2d7/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1005 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1025 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:72323 (70.6 KiB)  TX bytes:85135 (83.1 KiB)
          Interrupt:22 Base address:0xc000
ping yahoo.com from my desktop (10.10.10.101)
Code:
PING yahoo.com (98.139.183.24) 56(84) bytes of data.
64 bytes from ir2.fp.vip.bf1.yahoo.com (98.139.183.24): icmp_seq=1 ttl=49 time=412 ms
64 bytes from ir2.fp.vip.bf1.yahoo.com (98.139.183.24): icmp_seq=2 ttl=49 time=405 ms
64 bytes from ir2.fp.vip.bf1.yahoo.com (98.139.183.24): icmp_seq=3 ttl=49 time=396 ms
64 bytes from ir2.fp.vip.bf1.yahoo.com (98.139.183.24): icmp_seq=4 ttl=49 time=421 m
iam so confused. what i need is i want to enable eth0 and eth1 and can browse internet from my desktop and laptop.
 
Old 05-30-2012, 07:50 AM   #9
NM04
Member
 
Registered: Jan 2011
Distribution: Back Track,Fedora,centos
Posts: 240

Rep: Reputation: 14
psaruhang,
dont be confused and dont panic, do one thing draw a diagram of your network along with ip's and list the problems below the diagram and then post it here.

regards,
nm
 
Old 06-04-2012, 09:22 PM   #10
KinnowGrower
Member
 
Registered: May 2008
Location: Toronto
Distribution: Centos && Debian
Posts: 347

Rep: Reputation: 34
Due to internet issue at my side, i was unable to login.ISP took 3-4 days to fix this. Any way, i am back..

Paruhang, Please paste the output of the following command

route -n

Last edited by KinnowGrower; 06-04-2012 at 09:47 PM.
 
  


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
why does my laptop pc have a eth0 and eth1 when i only have 1 network card? neilcpp Linux - Networking 9 05-26-2009 03:01 PM
My Internet and Network are Down (eth0, eth1) alMubarmij Mandriva 2 02-19-2009 02:30 AM
Network apearing as eth1 not eth0... madspikes Linux - Networking 9 03-07-2007 09:19 PM
Wireless network on eth1 diabled Ethernet eth0 and eth0 never comes back tadatoshi Linux - Wireless Networking 4 09-23-2004 05:57 PM
eth0 and eth1 with 2 network interfaces codegomer Linux - Networking 12 04-20-2004 10:04 PM

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

All times are GMT -5. The time now is 09:06 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