Aleksandar's computer workshop
Let's see what Aleksandar was fixing today.
My findings, tips & tricks related to computers, internet, programming and other stuff I was working with.

Adding extra IP(s) to one network interface in RHL

February 29, 2008 21:13 by Aleksandar

To permanently add one or more IP's to network interface in RedHat Linux is quite easy if you follow this steps:

  • Go to the /etc/sysconfig/network-scripts/ directory
    cd /etc/sysconfig/network-scripts/
  • Copy the interface file that you want to add the IP to, and give it the same name as the current file, with ‘:0′ added (or :1, :2, depending on how many IPs are on this interface).
    cp ifcfg-eth0 ifcfg-eth0:0
  • Edit the new file, and you only have to change a few things
    > Change IPADDR= to your new IP address
    > Change DEVICE= to add :0
    (depending if this is the 2nd IP on that interface)
    > Remove DHCP_HOSTNAME (or set it to what it needs to be)
    > remove the HWADDR entry
  • Save the file that you just were working on
  • Restart the network interfaces
    /etc/init.d/network restart
  • Done!

 

So here are the examples:

Original file ifcfg-eth0 looks like

# Intel Corporation 82557/8/9 [Ethernet Pro 100]
DEVICE=eth0
BOOTPROTO=none
BROADCAST=192.168.5.255
HWADDR=00:06:5B:38:C8:5D
IPADDR=192.168.5.230
NETMASK=255.255.255.0
NETWORK=192.168.5.0
ONBOOT=yes
GATEWAY=192.168.5.1
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes

Config file ifcfg-eth0:0 for second IP looks like:

DEVICE=eth0:0
BOOTPROTO=none
BROADCAST=192.168.5.255
IPADDR=192.168.5.20
NETMASK=255.255.255.0
NETWORK=192.168.5.0
GATEWAY=192.168.5.1
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
ONPARENT=yes


Tags:
Categories: Linux | Networking
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

How to change Name Server (DNS Client) Settings under Linux

February 29, 2008 21:05 by Aleksandar
In order to be able to use conical names you have to use name servers (also called DNS servers) which will convert some name into IP address. I will here show you where are configuration files under Linux

Edit /etc/resolv.conf which can like this:
nameserver 192.168.1.1
nameserver 10.0.0.138

Also you might hardcode some IP's in hosts file. It looks like this:
127.0.0.1 localhost.localdomain localhost
194.109.6.67 ns.xs4all.nl

To have your new settings valid you have to restart the computer or do this in command line which will restart all your network services and devices:

/etc/init.d/network restart

If you are connected with SSH be patient connection will be restored.