PDA

View Full Version : [ubuntu] How to ping eth0 from eth1 on my linux machine?



nitish777
October 20th, 2010, 03:49 PM
I have a linux machine with 2 ethernet ports(eth0 and eth1). eth0 is connected to a router which assigns it an IP address 192.168.1.2. eth1 is connected to a switch and I assigned it an IP address 192.168.1.254 using "ifconfig eth1 192.168.1.254 netmask 255.255.255.0 up". How do I ping eth0 from eth1?

psusi
October 20th, 2010, 04:02 PM
Is the switch also connected to the router?

nitish777
October 20th, 2010, 04:04 PM
No. Its not.

Mr_Mischif
October 20th, 2010, 04:39 PM
eth1 has to be connected to a network in order to ping another computer, you'll have to connect eth1 to the same router as eth0 to make it work.

psusi
October 20th, 2010, 04:48 PM
No. Its not.

Then your question makes no sense. How do you expect the packet to get from one to the other without a connection between them?

SeijiSensei
October 20th, 2010, 06:40 PM
First it's certainly possible to ping one interface on a machine from another like this:

ping -I eth0 ip.addr.of.eth1

however the OP's setup probably won't work as configured. First you'll probably need to enable IP packet forwarding in the kernel by setting the "net.ipv4.ip_forward" switch to 1 in /etc/sysctl.conf and rebooting. Second you need to assign eth1 to another network besides 192.168.1.0/24. Give it 192.168.2.1/255.255.255.0 and you should be able to run

ping -I eth0 192.168.2.1