here are different ways of putting static ip with linux. assuming the system has a properly connected RJ-45 network cable with a working well broadcasting NIC card, using any of the 21 redhat-based linux distro with reference here
if you would like to have an ip address of 192.168.2.221 for eth0 without any default gateway, as root from CLI, simply issue any of the below commands:
# ifconfig eth0 192.168.2.221 up
optionally combined with:
# route add -net 192.168.2.0 netmask 255.255.255.0 eth0
another sets are:
# ifconfig eth0 192.168.2.221 netmask 255.255.255.0
# ifconfig eth0 192.168.2.221 netmask 255.255.255.0 up
by default, it would put the ip address and make the NIC operational without any issues to kernel drivers.
an alternative way is using static eth0 config file. you could launch your fave CLI editor, edit /etc/sysconfig/network/network-scripts/eth0 and paste the ff:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DEVICE=eth0
BOOTPROTO=none
BROADCAST=192.168.2.0
IPADDR=192.168.2.221
NETMASK=255.255.255.0
NETWORK=192.168.2.0
ONBOOT=yes
TYPE=Ethernet
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
and remember to restart the NIC service to take effect like so
#/sbin/service network restart
IP ADDRESS VERIFICATION:
to see your current IP address settings from CLI, just issue any of the below commands from root:
#ifconfig
#ifconfig eth0
#ip address
DEFAULT GATEWAY:
supposed that your default gateway is 192.168.2.1, just issue
#route add default gw 192.168.2.1
or the oldest way around - by editing the static config file /etc/sysconfig/network and making sure it contains following line
GATEWAY=192.168.2.1
then restart your NIC (network) service again
/sbin/service network restart
ROUTE VERIFICATION:
#route -n
#netstat -arn
#ip route show
RECEIVING/SENDING VERIFICATION:
you should be able to see your default route IP address from the very last line of your screen. and by doing so
#ping 192.168.2.1
would confirm that your gateway is reachable at this point.
overall, we could just issue altogether like
#ifconfig eth0 192.168.2.221 netmask 255.255.255.0 default 192.168.2.1 up
and ping the router from the host.
***Note that doing the CLI command is not a permanent state after reboot.
DISABLING ETHERNET/NETWORK FUNCTIONS:
these are your alternatives then
#ifup eth0
#ifdown eth0
#/sbin/service network stop
at any time, you may replace eth0 with eth1 or such. that goes the same with ip address and default gateway.
if you are having problems with your NIC for negotiation problems, link status and/or you might want to change your ethernet card settings, try
# ethtool eth0
If your gateway is supposed to forward your packets to the internet, you could check if your box can reach the internet without any further DNS setup, this can be done by pinging an IP address located from WWW like
#ping 198.6.1.2
Subscription
Categories
- HowTos (612)
- Linux Devices (40)
- Linux Diggs (620)
- Linux News (1541)
- Linux Videos (24)
Recent Posts
Blog Archive
-
▼
2007
(340)
-
▼
July
(107)
- AMSN messenger install howto
- firefox browser - yum update howto
- kopete messenger install howto
- Gaim pidgin messenger install howto
- xmms - multimedia player install howto
- UltraDMA - speedup your harddisk howto
- sabayon - user profile manager howto
- 50 quick linux command tips part 3
- No negotiations with Microsoft in progress
- connect SamSung D820 mobile to linux howto
- yum from ISO image or CD install howto
- missing portmap reinstall howto
- 50 quick linux command tips part 2
- 50 quick linux command tips part 1
- desktop wiki install howto
- NASA tests Linux for spacecraft control
- warzone 2100 strategy 3d game install howto
- motd - message of the day
- more with kernel name version howto
- stop and start networking service howto
- change network proxy preference howto
- alexa firefox toolbar plugin install howto
- reboot / halt system via CLI howto
- gparted partitioning install howto
- google picasa install howto
- pine and pico install howto
- adobe/macromedia flash player test and install howto
- realplayer install howto
- Microsoft's TrueType core fonts install howto
- Why Choose Fedora? (Fedora vs. Ubuntu)
- Microsoft vs Opensource
- the df command
- linux possessed by monsterz
- change display setting howto
- NTP clock synchronization howto
- qtparted partitioning magic install howto
- host name and host aliases explained
- IP aliasing - virtual IP howto
- viruskiller on linux
- change keyboard language setting
- changing ethernet card settings howto
- TIP: WiFi with chillispot and linux
- play tennis the linux way
- sudoku game install howto
- my linux box talked to me
- CD/DVD burning software install howto
- A SYSAD BLOG - LINUX: list out active host connect...
- list out active host connection howto
- more with linux command named history
- GnuPG and enigmail thunderbird add-ons
- PDF file readers install howto
- digikam - KDE photo management install howto
- gnome floppy formatter
- f-spot Gnome photo manager install howto
- VLC media player install howto
- ping IP subnet block howto
- TIP: find and delete files recursively
- list out opened host ports howto
- TIP: linux process priority scheduling management
- TIP: spammer sending email using squid
- remount partition as read only howto
- additional swap file howto
- CrossOver install howto
- system-config-securitylevel-tui and lokkit howto
- format a windows partition from linux hadrdisk
- TIP: monitoring while mounting USB devices
- zero-sized a file without permission / ownership c...
- TIP: auto create mail spool when adding user
- md5sum checksum howto
- IP address to country lookup howto
- gnome mail notification install howto
- add new harddisk to existing linux system
- TIP: block an IP address
- disk space report
- more trace route command alternatives
- changing your hardware / software clock howto
- other interesting ping commands
- send email via CLI howto
- adding static route howto
- send message to all logged in users
- unzip zip untar tar bzip2 bunzip2 gzip gunzip file...
- format of /etc/passwd, /etc/shadow and /etc/group
- remove user's cron jobs howto
- find the user's files howto
- passphraseless + passwordless ssh howto
- passwordless ssh howto
- X11 Forwarding via ssh howto
- skype install howto
- disable IPv6
- lsusb - list all USB devices
- make yum faster
- lspci - list all PCI devices
- kill a process
- beginners CLI guide for static ip address
- the pidof command
- retrieve data from mysql using bash script
- VirtualBox install howto
- call bash script inside php web page
- alternative linux browsers
- last / currently logged in users
-
▼
July
(107)
Thursday, July 5, 2007
beginners CLI guide for static ip address
Subscribe to:
Post Comments (Atom)
ILoveTux - howtos and news | About | Contact | TOS | Policy
0 comments:
Post a Comment