Link to home
Start Free TrialLog in
Avatar of entercite
entercite

asked on

how to assign IP to eth1 linux 6.2

Hello all,

One question how can I assign a IP to one of my two nic cards eth1. I need to make this one connect to my windows machine directly. Anything ideas.

Dave
Avatar of tibori
tibori

which distribution(Redhat, Caldera, Suse etc.) do you have?
Redhat(and Suse??) have a utility called Linuxconf, which makes configuring hardware a bit easier, than editing a text file. If you want to find out if you have linuxconf on your system, type:
whereis linuxconf
To use linuxconf just type /yourpath/linuxconf(under X) or /yourpath/linuxconf --text
If you don't have linuxconf(or netconf, or netcfg), you can look under /etc/sysconfig/network-scripts and copy the file ifcfg-eth0 into the same directory and rename it to ifcfg-eth1 and then change the parameters that need to be changed on it(device,ipaddress,netmask...etc). This is a bit dirty, but this is exactly what happens if you use linuxconf--except it looks cleaner I guess. Once you create the file, reboot, or run the ifconfig utility as such:
ifconfig eth1

Connecting to the Windows machine, is another matter. Get to the point where you can ping each machine from the other.
Good luck
you need a crossover cable if you want a direct connection (should be available anywhere category-5 cables with rj-45 connectors are sold like your local computer store).  the crossover swaps transmit and receive signals so that it emulates connecting to a hub.  otherwise, you can just connect them together using a hub.

it's pretty easy to configure eth1.  use /sbin/ifconfig (man ifconfig) with something like the following:

assume your win machine has ip address of 192.168.1.101 and your linux machine has an ip address of 192.168.1.102 and assume that you're using a class-c netmask 255.255.255.0

/sbin/ifconfig eth1 192.168.1.102  netmask 255.255.255.0
/sbin/ifconfig eth1 up
/sbin/ifconfig -a (this will see if everything looks ok)

your addresses can be different and your netmask can be different but it is very important that your netmasks are the same or you won't be able to talk to each other.

Maybe you wanna connect your linux machine directly with internet as a gateway and then use windows machine to share the internet,  I assume.
So you need to give two IP addresses to two nic on your linux machine.

Except using linuxconf as they have suggested, you can also enter the /etc/rc.d directory, modify your rc.inet1 as follows:
   IPADDR  ="61.194.130.3"     # this is your ISP gives you, for example.
   NETMASK  ="255.255.255.0"   # netmask for your first nic
   NETWORK  ="61.114.130.0"    # the first network
   BROADCAST ="61.114.130.255" # broadcast address for the first network
   GATEWAY  ="61.114.130.1"    # default gateway address of your first network, provided by ISP
   IPADDR1  ="192.168.0.1"     # your second IP address for eth1
   NETMASK1="255.255.255.0"    # netmask for it
   NETWORK1="192.168.0.0"      # and so on  
   BROADCAST1="192.168.0.255"

   /sbin/ifconfig eth0 $ {IPADDR}    broadcast ${BROADCAST}metmask ${NETMASK}
# set up the first nic
   /sbin/ifconfig eth1 $ {IPADDR1} broadcast $ {BROADCAST} metmask $ {NETMASK}
# set up the second nic
   /sbin/route add -net $ {NETWORK} netmask $ {NETMASK}
        /sbin/route add default gw $ {GATEWAY} metric 1
        /sbin/route add -net $ {NETWORK1} netmask $ {NETMASK1}
# make them active

OK, give the nic on your windows machine IP address like 192.168.0.2, and they are both on the internet now.
Avatar of entercite

ASKER

ezlee,

You say"linux machine directly with internet as a gateway and then use windows machine to share the internet"

Here is what I have:
1) cable modem router...
2) 16 slot hub
3) a linux 166 with 2 nics
4) windows 2000 adv server
5) a few other pcs but who cares

modem connect to hub for this I needed a crossover cable.

eth0 connects to hub
eth1 connects to server nic with a crossover cable.

the other PCs on my hub I do not care about firewall protection.

These commands seem strange:
/sbin/ifconfig eth0 $ {IPADDR}    broadcast ${BROADCAST}metmask ${NETMASK}
# set up the first nic
   /sbin/ifconfig eth1 $ {IPADDR1} broadcast $ {BROADCAST} metmask $ {NETMASK}
# set up the second nic
   /sbin/route add -net $ {NETWORK} netmask $ {NETMASK}
        /sbin/route add default gw $ {GATEWAY} metric 1
        /sbin/route add -net $ {NETWORK1} netmask $ {NETMASK1}
# make them active

I am so new to linux. case matters and spacing and everything is odd. I take all the items with {} around them should have an IP in there? or are those part of the actual command Well I will see tomorrow when I get errors.

Thank you all for you ideas,
Dave
those commands are copied directly from the startup files and are setup for variable substitution from the startup scripts.

like i wrote above, just use the command i gave you above.

also, do 'netstat -nr' and make sure your default route is looking at the correct interface (the cable router)

you may have to add a route to the windows box.  let me know if you need help with this.

it would be helpful if you could give us your ip addresses and netmasks.  you can get this from your cable router and/or win box.
msako,

 I have had some sucess... I have my linux and win2k server pinging each other. The linux box is live to the internet.
but the windows machine is not.

my IP ok I tell you them:
linux
eth0 24.163.167.105
eth1 192.168.0.1

windows
nic 192.168.0.2

What do you think is wrong?

Dave
check the netmasks on both systems for the 192.168.0 network and make sure they are set to 255.255.255.0

what you are trying to do is turn your linux box into a router.  you need to have your kernel setup for that.
Correction I fixed some stuff...
I can ping my linux from my windows machine... and linux can ping windows. what I cannot do is get a internet connection from my w2k server. Nor can I get into my server from an outside computer. But I have internet connection with my linux machine


ifconfig -a
eth0
link encap:My NIC address is here
inet addr:24.163.164.13 Bcast:255.255.255.255 mask:255.255.252.0
UP BROADCAST RUNNING MTU:1500 Metric:1
RX packet:856 errors:0 overruns:0 frame:0
TX packet:690 errors:0 overruns:0 carrier:0
collisions:48 txquelen:100
Interrupt:9 Base address:0xfc00

eth1
link encap:My other NIC address is here
inet addr:192.168.0.1Bcast:192.168.0.255 mask:255.255.255.0
UP BROADCAST RUNNING MTU:1500 Metric:1
RX packet:118 errors:0 overruns:0 frame:0
TX packet:12 errors:0 overruns:0 carrier:0
collisions:0 txquelen:100
Interrupt:10 Base address:0xff80

lo
link encap:local loopback
inet addr:127.0.0.1 mask:255.0.0.0
UP loopback RUNNING MTU:3924 Metric:1
RX packet:18 errors:0 overruns:0 frame:0
TX packet:18 errors:0 overruns:0 carrier:0
collisions:0 txquelen:0


I have downloaded this
ipmasqadm available from:
http://juanjox.kernelnotes.org/#ipmasqadm 

Help,
Dave

Think about follwoing:

what is default gateway address of the windows machine, is it 192.168.0.1?

Does the "routed" daemon started on your linux machine?

Does your file /etc/rc.d/rc.local has such line like "ipfwadm -F -a m -S 192.168.0.0/16 -D 0.0.0.0/0"?

If you don't have ipforwarding and ip-Masquerade, you need to have your kernel to be rebuilt with these two parameters chosen.



 
ezlee,

The default gateway address of the windows machine, is 192.168.0.1?

Does the "routed" daemon started on your linux machine? I do not know ! Would I see that in the lilo boot up? I will watch. If not how do I include it in bootup?

Does your file /etc/rc.d/rc.local has such line like "ipfwadm -F -a m -S 192.168.0.0/16 -D 0.0.0.0/0"?

If you don't have ipforwarding and ip-Masquerade, you need to have your kernel to be rebuilt with these two parameters chosen.

I believe I have these. I have redhat 6.2 and I have seen these when I typed
"ls /proc/sys/net/ipv4" I see ip_forward, ip_masq_debug

Is this all I need then? or do I have to rebuild kernel?

How do I view the file rc.local? do I have to use vi or I mean how do I open it? do I type vi rc.local ?

I know I am getting close to making this work. Hope it will be soon,

Dave
ezlee,

  Still waiting for a reply. Hope this problem has an answer?

Dave
ASKER CERTIFIED SOLUTION
Avatar of moonbeam012200
moonbeam012200

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial