Network Configuration In order to download stage3 tarball and portage snapshot from Gentoo website, you have to connect to the inter...

Gentoo Network Configuration

Network Configuration


In order to download stage3 tarball and portage snapshot from Gentoo website, you have to connect to the internet. Connect to internet the way you like. The most common ways to connect to internet are using an ethernet cable or using wireless network. If you want to connect to internet using ethernet cable just plugin the cable wire and try to ping any outside server like http://www.google.com for example. If the result is unknown host (that is if you’re not connected) then you’re most probably haven’t taken an IP address yet. Use the command:
dhcpcd eth0
to get an IP address (Make sure to change the ‘eth0‘ part with your ethernet interface. use the command ‘ifconfig -a‘ to see all of your interfaces) and try to ping google again and this time it should work (If it doesn’t, then most probably your network is down).
If you want to connect to internet using a wireless network then you can configure your wireless interface (most probably will be wlan0. check with ‘ifconfig -a‘ command) using the tool ‘iwconfig‘. Or better, you can use the famous ‘wpa_supplicant‘ program to handle your wireless network and get you connected right away (note: if your wireless network is encrypted with WPA encryption algorithm then you have to use ‘wpa_supplicant‘ program). I prefer using ‘wpa_supplicant‘ program by the way. To use ‘wpa_supplicant‘ program you have to write some configuration files first. open up ‘/etc/conf.d/net‘ with your favorite editor (I prefer Vim. But, you better use another editor like ‘nano‘ because Vim is complex to use):
nano /etc/conf.d/net
and write these lines:
# Prefer wpa_supplicant over wireless-tools
modules=( “wpa_supplicant” )
# It’s important that we tell wpa_supplicant which driver we should
# be using as it’s not very good at guessing yet

wpa_supplicant_wlan0=”-Dwext”
(notice the wlan0 part ! you should change it with your wireless interface, I don’t have to tell you now). Alright, save the file and exit (pressing CTRL+x will close the file and nano will ask you if you want to save or not and will ask about the filename. Just save the file with the same filename).
After configuring ‘/etc/conf.d/net‘ you have to write the ‘wpa_supplicant‘ configuration file (most probably will be ‘/etc/wpa_supplicant/wpa_supplicant.conf‘). Open the ‘wpa_supplicant‘ configuration file with ‘nano‘:
nano /etc/wpa_supplicant/wpa_supplicant.conf
and write this configuration if your wireless network is WEP encrypted:
# The below line not be changed otherwise we refuse to work
ctrl_interface=/var/run/wpa_supplicant
# Ensure that only root can read the WPA configuration
ctrl_interface_group=0
# Let wpa_supplicant take care of scanning and AP selection
ap_scan=1
# Simple case: WPA-PSK, PSK as an ASCII passphrase, allow all valid ciphers
network={
ssid=”name_of_your_ssid”
key_mgmt=NONE
wep_key0=”your_network_key”
# The higher the priority the sooner we are matched
priority=5
}
or write this configuration if your wireless network is WPA/WPA2 encrypted:
# The below line not be changed otherwise we refuse to work
ctrl_interface=/var/run/wpa_supplicant
# Ensure that only root can read the WPA configuration
ctrl_interface_group=0
# Let wpa_supplicant take care of scanning and AP selection
ap_scan=1
# Simple case: WPA-PSK, PSK as an ASCII passphrase, allow all valid ciphers
network={
ssid=”name_of_your_ssid”
psk=”your_network_key”
# The higher the priority the sooner we are matched
priority=5
}
now save the file and exit nano. At this stage, you’re ready to connect:
wpa_supplicant -iwlan0 -Dwext -c/etc/wpa_supplicant/wpa_supplicant.conf &
(notice the latest ampersand character ‘&‘, this way ‘wpa_supplicant‘ will be running in the background but you will see its output when it comes).
if you want to understand the command line of ‘wpa_supplicant‘, then read its man page ‘man wpa_supplicant‘ (come on, don’t be lazy). Now, you’re connected and ready to go.
(NOTE: if you’re still not internet connected while you’re connected to your wireless network, then probably you didn’t took an IP address. Use the command ‘dhcpcd wlan0‘ to take one).

0 comments: