Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Networking & Security
  • Search

start static ip from comand line

Having problems getting connected to the internet or running a server? Wondering about securing your box? Ask here.
Post Reply
Advanced search
6 posts • Page 1 of 1
Author
Message
slackeast
Tux's lil' helper
Tux's lil' helper
Posts: 83
Joined: Mon Oct 10, 2005 7:03 pm

start static ip from comand line

  • Quote

Post by slackeast » Wed Feb 13, 2008 9:58 pm

Ok, I know how to restart my dynamic ip over command line.

ifconfig eth0 down
ifconfig eth0 up

dhcpcd eth0

However, when I try to static.


ifconfig eth0 192.168.0.112 netmask 255.255.255.0 broadcast192.168.0.255 up

I try to access the internet but can't.

so I think I need a nameserver so I add

route add default gw 192.168.0.1

SIOCARDDRT: Network is unreachable

Any ideas what I'm doing wrong. I can always just start up /etc/init.d/net.eth0 but I'm just curious. J
Top
alex.blackbit
Advocate
Advocate
Posts: 2397
Joined: Tue Jul 26, 2005 8:04 pm

  • Quote

Post by alex.blackbit » Wed Feb 13, 2008 10:58 pm

of course it is quite long, but taking a look at the script to which /etc/init.d/net.eth0 points to may clear things up.
Top
slackeast
Tux's lil' helper
Tux's lil' helper
Posts: 83
Joined: Mon Oct 10, 2005 7:03 pm

  • Quote

Post by slackeast » Thu Feb 14, 2008 12:35 am

ya i looked through the script......from what I understood, which is probably very little, i couldn't figure out how they get the gateway in the routing table. I did see the nameserver correctly in resolv.conf. J
Top
daschapa
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 80
Joined: Fri Sep 01, 2006 7:32 pm

  • Quote

Post by daschapa » Thu Feb 14, 2008 12:37 am

Look up an example very much easier for your day to day

This is your /etc/conf.d/net file

Code: Select all

dns_domain_lo="yourdomain"

config_eth0=( "10.0.0.2 broadcast 10.0.0.255 netmask 255.255.255.0" )
routes_eth0=( "default gw 10.0.0.1" )
dns_servers_eth0="200.45.191.35 200.45.191.40"
And this is the way you can bring up your network

Code: Select all

/etc/init.d/net.eth0 start
Now, you'll need to edit the first file just once.
======================
Top
Jaglover
Watchman
Watchman
User avatar
Posts: 8291
Joined: Sun May 29, 2005 1:57 am
Location: Saint Amant, Acadiana

  • Quote

Post by Jaglover » Thu Feb 14, 2008 1:37 am

ifconfig eth0 inet 192.168.0.112 netmask 255.255.255.0
route add -net 192.168.0.0 netmask 255.255.255.0 eth0

These two commands suffice to get network going. If you want domain names to resolve put a valid nameserver into /etc/resolv.conf. That's it. Of course, this won't survive reboot.
Top
jcat
Veteran
Veteran
User avatar
Posts: 1337
Joined: Fri May 26, 2006 10:47 am

  • Quote

Post by jcat » Thu Feb 14, 2008 4:27 am

Jaglover wrote:ifconfig eth0 inet 192.168.0.112 netmask 255.255.255.0
route add -net 192.168.0.0 netmask 255.255.255.0 eth0

These two commands suffice to get network going. If you want domain names to resolve put a valid nameserver into /etc/resolv.conf. That's it. Of course, this won't survive reboot.
That adds no default gateway or any kind of route to the internet or another network.


This guy just needs to do as daschapa suggests and use the config file /etc/conf.d/net, I can't really think of a good reason why not to use the config file :wink: If the user regularly needs to switch from dhcp to a static IP address they should just create two config files and symlink the one that's needed to /etc/conf.d/net before restarting /etc/init.d/net.eth0





Cheers,
jcat
Top
Post Reply

6 posts • Page 1 of 1

Return to “Networking & Security”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic