Evil_TTL> show | s

ifconfig

Category:Linux -> CentOS

Setting up the network interface in CentOS 6.3

So you have a fresh installation of CentOS and you badly want to assign an IP address so you could download and install new apps. This is how you can do it. First, issue ifconfig command and see what network interfaces are up.

ifconfig-00.jpg

As you can see in the screenshot, there’s only one interface and it is a loopback interface. Ethernet interface is missing. To turn it on enter ifup eth0 command. To turn it off again use ifdown eth0. Now issue ifconfig and you will see eth0 in the output.

ifconfig-10.jpg

Now go to /etc/sysconfig/network-scripts. The file where you can configure the main network interface is called ifcfg-eth0. Use nano ifcfg-eth0 command to edit the parameters.

Static IP address configuration:

DEVICE="eth0 "
BOOTPROTO="static"
IPADDR="192.168.1.77"
NETMASK="255.255.255.0 "
ONBOOT="yes" // Change it from NO to YES so next time the interface would go up automatically
TYPE="Ethernet" 

To set up the gateway go to /etc/sysconfig and open the file called network. Change it appropriately:

NETWORKING=yes
GATEWAY
=192.168.1.1
HOSTNAME
=localhost.localdomain 

To set up DNS proceed to /etc and open the file resolv.conf and insert your preferred DNS servers:

nameserver 8.8.8.8
nameserver 4.2.2.2
search localhost 

If you need to get the IP address automatically from a DHCP server get back to /etc/sysconfig/network-scripts and make the following changes in ifcfg-eth0:

BOOTPROTO="dhcp" 


Category:Unix -> FreeBSD

Setting up the network interface in FreeBSD using DHCP

Temporary solution until the system is restarted:

# ifconfig //used to find out the interface name
dhclient em0
DHCPREQUEST on em0 to 255.255.255.255 port 67
DHCPACK from 192.168.1.1
bound to 192.168.1.11 
-- renewal in 21600 seconds

Permanent solution:

# cd etc/
# ee rc.conf
defaultrouter="DHCP"
ifconfig_em0="DHCP" 

ifconfig-20.jpg

By privilege15