Setting up a single Mandrake/Mandriva Linux PC with
static
ethernet IP address.
Assumes you have a simple network, you have run Mandrake's
Internet wizard and still cannot connect to the Internet.
For the following environments:
This_PC-->router/cable_modem
This_PC-->hub/switch-->router/cable_modem
This_PC-->hub/switch-->another PC running (working) internet
connection sharing
Not suitable for a computer that shares its connection (but may help
you understand some of the files/concepts) - see
Internet
connection sharing or
Internet connection
sharing with a dial-up modem for these scenarios.
First
check your cabling - can
Windows connect if you have a dual boot machine? Do they work on a
known good network?
For our purposes:
Network interface cards (
NICs)
are called eth0, eth1 etc in Linux
IP ADDRESS is a number
used to
uniquely identify a network interface
DEFAULT GATEWAY address
is the
IP address of the device connected to the internet eg. your router, or
PC running internet connection sharing (
ICS).
The address to use is the one allocated to the interface connected to
your internal network. It will almost certainly be in one of the ranges
in "Note about IP addresses" below. Most likely 192.168.0.1 ,
192.168.1.1 or 10.0.0.1
NAMESERVER address is the
IP
address of your internet service providers (ISP) nameserver - used to
look up the corresponding IP address of a human readable address like
www.google.com
HOSTNAME is a unique name
for
your computer - anything you like, for example linux.mylan.home or
zeus.greekgods or kevin but not www.google.com, www.microsoft.com...
Note about IP addresses:
Each interface on your network must have a different IP address. The
usual numbering schemes for private networks are 192.168.x.x or 10.x.x.x
The numbering scheme used should match that of your gateway device
(router, PC running internet connection sharing (ICS),cable modem etc)
if you have one. For example, if your router manual says the IP address
is 192.168.1.1 you will number your computer network interfaces
192.168.1.2, 192.168.1.3 etc.
You need to find out what your IP address and default gateway are -
these can be obtained from a working windows installation if you dual
boot, or your router/cable modem manual as above. You will also need
your nameserver IP address (get it from your ISP)
You will need to be root (administrator) to edit the files here.
To sign on as root - type su in a terminal (console), press enter
followed by your root password
Edit
/etc/sysconfig/network-scripts/ifcfg-eth0 - This is the main
config file for the interface.
It should read : (you can leave out anything on a line after #)
DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.1.2 # or
whatever your IP address is to be - see above
NETMASK=255.255.255.0 # or 255.0.0.0 if
your IP address is 10.x.x.x
NETWORK=192.168.1.0 # or 10.0.0.0
if your IP address is 10.x.x.x or 192.168.2.0 if your IP address is
192.168.2.x
BROADCAST=192.168.1.255 # or 10.255.255.255 if your IP
address is 10.x.x.x or 192.168.2.255 if your IP address is 192.168.2.x
ONBOOT=yes
MII_NOT_SUPPORTED=yes
/etc/resolv.conf should
contain
the nameserver address(es) - put the address of your ISPs nameserver
right at the top. eg:
nameserver 195.20.224.165
If you are using a router that provides DNS lookup
forwarding (many do - check the manual) you can put the IP address
of that in here e.g. 192.168.1.1 . If unsure, use the ISP's DNS address.
The default gateway and your hostname go in
/etc/sysconfig/network:
HOSTNAME=yourhostname_goes_here
NETWORKING=yes
GATEWAY=192.168.1.1 # or the IP address of your
gateway device - your default gateway
GATEWAYDEV=eth0
In a terminal, type:
iptables -t nat -D PREROUTING -i
eth0
-j loc_dnat
You may get an error with this - don't worry - if you do, just skip the
next line:
Add the above code to the bottom of
/etc/rc.d/rc.local.
This will bypass a proxy server Mdk will have set up if you ran the ICS
wizard.
Then type
ifup eth0 - this should
bring up the network
Then try it all out:
Try pinging your computers NIC (type "
ping
192.168.1.2" or whatever your IP address is) If you get errors,
then your NIC is not working - ask for help (see below).
If OK - Try pinging the gateway
If OK - Try browsing - if you cannot reach say, www.google.com, try
typing http://216.239.59.99 (IP address of google) into your browser
address bar.
(If you cannot reach a site by name, but can get it by IP address, you
have a name resolver (DNS) problem.
Check to make sure it all works across a reboot.
Once working, you should set up a firewall - see
http://www.shorewall.net/ click
on the 'standalone Linux system' link there.
If you are still having problems,
post the following information in the networking forum:
Overview of your problem - not just "I can't connect to the internet" -
what have you done/tried so far, what works, what doesn't?
Physical network set up - what plugs in to what
Output of "ifconfig" , "route -n" , "iptables -nvL" and "iptables -nvL
-t nat"
Results of all pings above.
Please
pass on your comments to
me - consider this work in progress.
If you live on the Isle of Wight (UK)
and you are still stuck, give me a call!
For other mandrake Linux problems, try
Mandrivausers.org
IOW PC - Isle of Wight ( UK ) computer help for you & your business
0789 150 9466 / IW 731467 / IW 897033