venerdì 20 dicembre 2013

CentOS Example Network Interface Configuration

USING THE DHCP

[root@centoshost ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=centoshost
GATEWAY=192.168.1.1
GATEWAYDEV=eth0
[root@centoshost ~]# diff /etc/sysconfig/network{.orig,}
2a3,4
> GATEWAY=192.168.1.1
> GATEWAYDEV=eth0
[root@centoshost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=**:**:**:**:**:**
TYPE=Ethernet
UUID=********-****-****-****-************
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
[root@centoshost ~]# diff /etc/sysconfig/network-scripts/ifcfg-eth0{.orig,}
5c5
< ONBOOT=no
---
> ONBOOT=yes
[root@centoshost ~]# ifup eth0

Determining IP information for eth0... done.
[root@centoshost ~]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr **:**:**:**:**:**
          inet addr:192.168.1.116  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::215:5dff:fe01:6705/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:524 errors:0 dropped:0 overruns:0 frame:0
          TX packets:223 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:55083 (53.7 KiB)  TX bytes:31077 (30.3 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

[root@centoshost ~]#

NOT USING THE DHCP

[root@centoshost sysconfig]# diff /etc/sysconfig/network-scripts/ifcfg-eth0{.orig,}
5c5
< ONBOOT=no
---
> ONBOOT=yes
7c7,11
< BOOTPROTO=dhcp
---
> BOOTPROTO=no
> GATEWAY=192.168.1.1
> IPADDR=192.168.1.10
> NETMASK=255.255.255.0
> PEERDNS=no
[root@centoshost sysconfig]# cat /etc/resolv.conf
; generated by /sbin/dhclient-script
search WAG54GS
nameserver 85.37.17.8
nameserver 85.38.28.73
[root@centoshost sysconfig]# cat <<EOF > /etc/resolv.conf
> nameserver 85.37.17.8
> nameserver 85.38.28.73
> EOF
[root@centoshost sysconfig]# cat /etc/resolv.conf
nameserver 85.37.17.8
nameserver 85.38.28.73
[root@centoshost sysconfig]# ifdown eth0
[root@centoshost sysconfig]# ifup eth0

Determining IP information for eth0... done.
[root@centoshost sysconfig]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr **:**:**:**:**:**
          inet addr:192.168.1.10  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::215:5dff:fe01:6705/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2608 errors:0 dropped:0 overruns:0 frame:0
          TX packets:473 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:348608 (340.4 KiB)  TX bytes:62053 (60.5 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

[root@centoshost sysconfig]#