Can't connect to internet using a static ip
Hello
I'm quite new to linux, and I am trying to write a script that will connect to the internet using a static ip. I have tried dhcpcd and iproute2 in many ways succeeding. Using dhcpcd with a dynamic ip works perfectly. Any help would be greatly appreciated. Thanks! |
Code:
Static IP => 1. You need to have some kind of router. A cable modem, DSL or a dial-up connection will all work OK. 2. Your static IP address needs to be compatible with the router's internal "LAN" address. It would be simpler if you just let your router assign a dynamic address: that way everything's guaranteed to be set up for you. 3. The router needs to connect to the internet (with it's assigned, external "WAN" address). 'Hope that helps PS: Some good links: http://www.linuxhomenetworking.com/ http://www.pcworld.com/article/18423...7_edition.html http://www.aboutdebian.com/network.htm |
Yes, I know it's a lot easier to use a dynamic ip, but I really need to use a static ip, so it is not an option.
Also, i'm don't really understand the code part of your response. What I've tried (among other things) is this : Code:
# ip address gateway (router) I must be missing something, but I don't know what. |
Quote:
Quote:
Q: What does ifconfig say? Q: Can you "ping" your gateway? Q: Is your gateway connected to the Internet? Q: Are your gateway and IP on the same network (i.e. do the subnet masks and IP network addresses match)? Q: Have you looked at the links I cited? Or can you point to any links you've been using? |
What distro are you using? Different distros have slighty different ways of setting static IP addresses. Commonly, it is done in a configuration file in /etc.
In Debian, it's done by editing /etc/network/interfaces and entering the following: Code:
allow-hotplug eth0 If you google [distro name] static IP you will likely find the information you need. |
Hi, frankbell -
Quote:
But the main point is: with a dynamic IP, you can basically "push a button" and things will "just work". Unless you're explicitly assigned a static IP (by your administrator, or by your ISP), you need to know at least a *little* bit about TCP/IP to get things working. I asked a few questions, I gave a few links. I tried to point the OP in the right direction. Let's see if he responds :) |
Hi,
Welcome to LQ! Several ideas have been presented. Below is procedure then a script to assign a IP via the cli. A few things you would need to know; available IP, Gateway, device Ethernet or Wireless, Your Key and access point if wireless. First, IP available for your LAN? What is the Gateway? Device is Ethernet (Eth0,1,2,3) or Wireless (wlan0)? Hopefully all drivers & firmware are in place and the device is available. If wireless you can do from cli as root: 'iwlist wlan0 scan' (omit the ticks) to get the available access. If there is security setup then you will need the keys. I would setup a static IP first, do as root from cli; For Ethernet(wired) use this part; Code:
~#ifconfig -a #get recognized devices For wireless use this part Code:
~#ifconfig -a #get recognized devices Code:
~#route -n #show the kernel route table Code:
sample '/etc/resolv.conf'; Code:
~# cat wlan.sh You willl need to setup the '/etc/resolv.conf' with your ISP nameservers. Quote:
Just a few links to aid you to gaining some understanding; 1 Linux Documentation Project 2 Rute Tutorial & Exposition 3 Linux Command Guide 4 Bash Beginners Guide 5 Bash Reference Manual 6 Advanced Bash-Scripting Guide 7 Linux Newbie Admin Guide 8 LinuxSelfHelp 9 Getting Started with Linux 10 Linux Home Networking 11 Virtualiation- Top 10 The above links and others can be found at 'Slackware-Links'. More than just SlackwareŽ links! |
Hello
There's been a lot of question and comments while I was away, I'll try to answer them all. 1) Why do I need static IP? Because I do. 2) How am I sure that my IP and gateway addresss are correct. First, the gateway: - If I type its address in a web browser, I can see the router's settings - If I type the command "ip neigh show", I can only see this address, and it is reachable - If I connect to the internet using "dhcpcd" and then check "ip route show", I see this address set as the gateway. 3) What does ifconfig say? Nothing, since I do not have it. 4) Can you ping your gateway? Yes 5) Is your gateway connected to the internet? Yes. Note that I said I was able to connect using a dynamic IP, using the same gateway, so this is not a problem. 6) Are your gateway and IP on the same network? Yes 7) Have you looked at the links I cited? Some of them (didn't have the time to check them all). Didn't find anything relate to my problem specifically. Also, before posting, I search on the internet for a solution for about 2 days. Maybe I'm just bad at searching, or no one tries to do what i'm doing o_O 8) What distro are you using? Linux From Scratch. 9) Issuing a dhcp* command seems to me to be counter-intuitive to "static host configuration." ? YES! I totally agreed. I saw somewhere it was possible, that is what I'm trying it. I've also tried to connect using iproute2. I'm open to suggestions though. 10) Welcome to LQ? Thank you :D 11) What is the gateway? A router, with eth0 as a device (no wireless). I see a lot of examples using ifconfig, but I don't have it. I read that iproute2 is the utility to replace it (and other tools too), but I don't understand fully how it works. I'm posting this now and will be reading some more on linux networking. Thanks for all the answers. |
Hi,
We should have been told early on that this LFS. Your install will depend on the base GNU/Linux used for LFS. Moved: This thread is more suitable in LFS and has been moved accordingly to help your thread/question get the exposure it deserves. :hattip: |
Quote:
still new to Linux and already using LFS is certainly an interesting combination. Could you also post the version of LFS? What is the output of ip link Have you configured your card according to those sections in the book? http://www.linuxfromscratch.org/lfs/...r07/hosts.html http://www.linuxfromscratch.org/lfs/...7/network.html In other words, please post the following files: /etc/hosts /etc/sysconfig/network-devices/ifconfig.eth0/ipv4 /etc/resolv.conf /etc/udev/rules.d/70-persistent-net.rules |
Hello again
Found the solution to my problem here : http://roy.marples.name/cgi-bin/man-cgi?dhcpcd Code:
#sample of static address configuration Thank you for your time! |
All times are GMT -5. The time now is 08:59 PM. |