If you're reading this, its most likely that you have no clue how to connect to the LAN Internet (also referred as Cable connection) using your brand new Linux operating system. Don't feel bad, you're not alone.
Everybody had to ask few questions on how to get the freakin' internet work, and without the help of some folks on the online, I would have still been using Microsoft's Windows because connecting to the internet with it is so easy.
Internet is an important element when it comes to general computing, so if someone wants to introduce a new computer system such as Linux, at least let it run the most used service.
Now remember, you will not connect directly to the internet. Basically I'm going to teach you how to connect to a network that will enable you to use the internet. I'm not going teach how to use a certain Distro, or a certain GUI. Distro's network settings sometimes differ, so what I'm going to help you with is ignoring all the distro's default settings and write your own internet .sh script that would let you connect to the internet as easy as 1, 2, 3... So lets see what you have: A cable coming down from outside directly plugged to your NIC (Network Card), normally if you have one NIC, it would be named: eth0 (ethX -> X will change if you have more than one NIC). In this example we're gonna use only one NIC to enable Internet on one station only. General internet connection requirements:
Hope you enjoyed reading this comprehensive guide to help you connect to the Internet on Linux using your cable.
Everybody had to ask few questions on how to get the freakin' internet work, and without the help of some folks on the online, I would have still been using Microsoft's Windows because connecting to the internet with it is so easy.
Internet is an important element when it comes to general computing, so if someone wants to introduce a new computer system such as Linux, at least let it run the most used service.
Now remember, you will not connect directly to the internet. Basically I'm going to teach you how to connect to a network that will enable you to use the internet. I'm not going teach how to use a certain Distro, or a certain GUI. Distro's network settings sometimes differ, so what I'm going to help you with is ignoring all the distro's default settings and write your own internet .sh script that would let you connect to the internet as easy as 1, 2, 3... So lets see what you have: A cable coming down from outside directly plugged to your NIC (Network Card), normally if you have one NIC, it would be named: eth0 (ethX -> X will change if you have more than one NIC). In this example we're gonna use only one NIC to enable Internet on one station only. General internet connection requirements:
- an IP address + netmask
- a Gateway address
- a DNS address
- and sometimes a Proxy server address.
- Your personal external IP address + netmask (will use 192.168.0.55 and netmask: 255.255.255.0 as example)
- Your network address (If your IP is xxx.xxx.0.xxx then your network address would be xxx.xxx.0.0) - The gateway's (Server) internal IP address (will use 192.168.0.1 as example)
- Your DNS (usually same as the gateway) internal IP address (will use 192.168.0.1)
- and finally, ask him if he uses a proxy server, write down it's IP address and port if the ISP uses one. (Will use 10.3.3.1 port 8080 as example; don't get shocked if the proxy's ip address is the same as the gateway and/or DNS).
- Path for Ifconfig
- Path for Route
To do that do the following, open a terminal and write down: haytham@sadusbox:/$ whereis ifconfig && whereis route You'll get something similar to: haytham@sadusbox:/$ whereis ifconfig && whereis route ifconfig: /sbin/ifconfig /lib/ifconfig ... route: /sbin/route /usr/share/man.... We're just interested in these: ifconfig: /sbin/ifconfig route: /sbin/route Now that you gathered enough information, open your favorite editor, (will use VIM here, know how to use your editor for the following commands, open, save as, close) Write down what is written in the box, and change the variables to your needs (Variables start from the START EDIT comment to the END EDIT comment) #!/bin/bash #-------START EDIT-------- #Setting some variables echo "Setting Variables..." NICNAME=eth0 EXTERNALIP=192.168.0.55 SUBEXTERNALIP=255.255.255.0 NETWORKIP=192.168.0.0 GATEWAYIP=192.168.0.1 DNSIP=192.168.0.1 IFCONFIG=/sbin/ifconfig ROUTE=/sbin/route #-------END EDIT-------- #Initialize external NIC IP address echo "Initialize external NIC ($NICNAME) IP address" $IFCONFIG $NICNAME $EXTERNALIP netmask $SUBEXTERNALIP up #Setting Network and Gateway Settings echo "Setting Network and Gateway Settings" $ROUTE add $EXTERNALIP $NICNAME $ROUTE add -net $NETWORKIP netmask $SUBEXTERNALIP $NICNAME $ROUTE add default gw $GATEWAYIP eth0 $ROUTE add -host 127.0.0.1 lo #Adding a DNS server echo "Adding a DNS" echo " " > /etc/resolv.conf echo nameserver $DNSIP > /etc/resolv.conf #Detecting default route settings, this may take 5 seconds of wait echo "Detecting pre-default route settings, this may take 5 seconds for probing" $ROUTE | grep default echo "..." echo "Internet is enabled, happy surfing..." Save this file as: internet.sh in your /home/user/ directory and then set its permissions to 755 by doing the following command: haytham@sadusbox:/$ chmod 755 /home/user/internet.sh You can now login as SuperUser and just write: haytham@sadusbox:/$ su Password: root@sadusbox:/$ sh internet.sh Internet should be smiling at you. If your ISP uses a proxy server address don't forget to add the proxy server's address (10.3.3.1 and port 8080) inside your favorite web browser so that you would be able to surf the pages and most importantly in your .bashrc script so that it would let you connect to the proxy from bash.To do that open with your favorite editor the file .bashrc and write the following in the first lines: export http_proxy=http://10.3.3.1:8080 export ftp_proxy=http://10.3.3.1:8080
No comments:
Post a Comment