Answer» hi, i need to configure the ethernet interface for the router and computer in a network. i understand we can use the ifconfig command. i read online that we can use ifconfig eth0 <ip address> up to activate the ethernet interface. we also can use ifconfig eth0 <ip address> netmask <netmask> to ASSIGN the IP address and netmask to the network adapter. so if i wanna config the router and each computer in the network, i have to do those set of COMMANDS for all??Some linux distributions have GUIs which do it all for you but underneath the covers they all use ifconfig route and /etc/resolv.conf, some also use /etc/defaultrouter /etc/gateways and /etc/nsswitch.conf
To get everything you need to contact the internet, you need to configure the NIC with your local LAN address, configure a route from your LAN to the internet, and be able to resolve addresses.
Configure the NIC with ifconfig and set your IP address and netmask for your LAN, and configure it up. On most distros there's a dhcp option to ifconfig so you can get everything you need from the your broadband modem. You'll need to find some way of making the computer remember this after a reboot. Some Unix distros will want you to put the address into a /etc/hostname.eth0 file and add the netmasks to /etc/natmasks, but most will want you to put all the information into a file such as /etc/sysconfig/network/ifcfg-eth0
Next, you need to configure a route to the internet. If you're configuring a system which is going to be a router then you'll need to know about routing protocols such as RIP, and will probably need to run a routing daemon such in.routed or in.rdisc. If your just setting up a computer which isn't a router itself, some Unix distros will let you run in.routed or in.rdisc to discover your route to the internet automatically, but they will DEPEND on your broadband modem supplying the information using something like RIP.
If your computer is not going to be a router itself then you can setup a default route to the internet with the route command, but your computer will forget it next TIME you reboot, some of them let you put the address of the default router in the /etc/defaultrouter file, but most will want you to put it int the /etc/sysconfig/network/routes file as above. To add a route manually use something like route add -net default gw 192.168.0.1, but check the syntax for your linux as it varies.
Finally to convert a web address into an IP address that your computer can talk to you need to configure DNS. Some unix distro's will require you to edit the hosts line in /etc/nsswitch.conf so it contains the keyword dns, but for most of them using DNS will be the default anyway. Then, all you will need to do is put a/some line(s) into /etc/resolv.conf which contain the keyword nameserver: and the address of your DNS server. You could either use your broadband modem's address here or you could use the DNS servers which your ISP provide.
E.g. for Solaris Code: [Select]# ifconfig hme0 192.168.0.2 netmask 255.255.0.0 broadcast 192.168.255.255 -TRAILERS up # route add -net default 192.168.0.1 # cat > /etc/resolv.conf nameserver 192.168.0.1 nameserver 194.106.33.42 ^D # and to remember for next reboot # echo 192.168.0.2 > /etc/hostname.hme0 # echo 192.168.0.1 > /etc/defaultrouter
E.g. for SuSE 9.3 Code: [Select]# ifconfig eth0 192.168.0.2 netmask 255.255.0.0 up # route add -net default gw 192.168.0.1 # cat > /etc/resolv.conf nameserver 192.168.0.1 nameserver 194.106.33.42 ^D # and to remember for next reboot # cat > /etc/sysconfig/network/ifcfg-eth0 BOOTPROTO='static' BROADCAST='192.168.255.255' IFPLUGD_PRIORITY='20' IPADDR='192.168.0.2' MTU='' NAME='ASUSTeK CK8S Ethernet Controller' NETMASK='255.255.255.0' NETWORK='192.168.0.0' REMOTE_IPADDR='' STARTMODE='ifplugd' UNIQUE='rBUF.lA1Zt0RGIZE' USERCONTROL='no' _nm_name='bus-pci-0000:00:05.0' ^D # cat > /etc/sysconfig/network/routes default 192.168.0.1 - - ^D #
|