Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
As soon as I type that, I am automatically disconnected from the internet. The only way I know how to get it back is to reboot. I tried eth0 up and eth0 down etc, but couldn't figure it out.
I not sure I completely understand what you want to do, but the static IP you are trying to use is a non-routable address and you can't connect to the internet with it. You can use it for your local area network.
On Slackware you'd typically set up your ip address, mask and gateway in:
/etc/rc.d/rc.inet1.conf
and your nameserver addresses in
/etc/resolv.conf
That's sufficient for a connection, in addition to disabling the DHCP server option on your router - if you're going to disable the DHCP server option on the router just set up a static ip etc in Windows aswell.
In windows, I get the DNS servers, etc, from my router, I didn't input them, but I have a static IP.
So in linux, do I need to get the information from my DHCP server, then disable dhcp, and set all the settings manually?
What is the ifconfig command to do that? Say my ip is 192.168.1.122 and my router is 192.168.1.100 (This might be called gateway in windows, the IP of my router)
the reason why you lost web access after changing the IP address of you eth0 (using ifconfig) is that the route to the default gateway was erased in the process. To regain access, you must do :
Code:
route add default gw ip_of_your_router eth0
To get your static address at boot-time, you must change the network settings for eht0, either using a GUI tool or by editing the config file. I don't know which it is for Slackware; fyi, on a FC2 the path to the file woulo be /etc/sysconfig/networking/devices/ifcfg-eth0.
In rc.local type /sbin/ifconfig eth0 x.x.x.x netmask=x.x.x.x up
x is your static ip address. Check the syntax (man ifconfig) for netmask. I'm uncertain if you should use = or not.
In ifcfg-eth0 set BOOTPROTO=none
You can also add the route command in rc.local as described by cidrolin to be sure it find the route at boot.
So in linux, do I need to get the information from my DHCP server, then disable dhcp, and set all the settings manually?
You've got a choice - either get the information via DHCP from the router or assign the information manually - presumably you already know your gateway ip aswell as your chosen static ip, you're netmask will be 255.255.255.0 - in Slackware you can use this file, /etc/rc.d/rc.inet1.conf to set up the relevant information - as an example with a gateway of 192.168.0.1, an ip of 192.168.0.2 and the corresponding mask:
(Part of a /etc/rc.d/rc.inet1.conf file with example values used)
Code:
# Config information for eth0:
IPADDR[0]="192.168.0.2"
NETMASK[0]="255.255.255.0"
USE_DHCP[0]=""
DHCP_HOSTNAME[0]=""
# Default gateway IP address:
GATEWAY="192.168.0.1"
If you have a look at /etc/rc.d/rc.inet1.conf you'll see the sections to fill in similar to the above - for your nameserver addresses simply use /etc/resolv.conf.
And I'd be back on the net, with my lan IP being 192.168.1.122?
2) I have entries in /etc/resolv.conf but I didn't put them there. If I disable DHCP, will they dissapear? (I'm asking because how else did they get there?)
Quote:
Your router will mostly likely give your machine an 192.xxx.xxx.xxx non-routable IP address.
Why do you not want to use the IP you obtained from your router?
3)What doyou mean non-routable IP?
The way it is now, I get a random lan IP 192.168.1.xxx (first 3 numbers are always the same) I sometimes want a static, or at least the ability to change my IP (question #1) because my router will route ports to a certain IP. If I don't change my IP, I will have to change several entries everytime I want to host a game/use bittorent/etc.
I was trying to run a public FTP server from my LAN.... my ISP gives me a public IP address which is actually assigned to my router cum switch.... the broadband router gives me a DHCP address.... which may change each time I turn on the machine. I want to keep it static so that I can assign my IP in the router's port forwarding configuration.
I tried doing it from Windows... its working perfectly.... but in linux... I am not able to access anything outside my LAN... unless I configure it as a DHCP client.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.