Introduction Of Linux Networking
To set the hostname temporarily
[root@station9 ~]# hostname station9.example.com
To view the hostname
[root@station9 ~]# hostname station9.example.com
Set hostname permanently
[root@station9 ~]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=station9.example.com
:wq!
Set ip address temporarily
[root@station9 ~]# ifconfig eth0 192.168.0.9 netmask 255.255.255.0 View the interfaces.
[root@station9 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:13:20:B7:1D:44
inet addr:192.168.0.9 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::213:20ff:feb7:1d44/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:48153 errors:4 dropped:0 overruns:0 frame:4
TX packets:21992 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:39512670 (37.6 MiB) TX bytes:1720318 (1.6 MiB)
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:1249 errors:0 dropped:0 overruns:0 frame:0
TX packets:1249 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0
RX bytes:1285258 (1.2 MiB) TX bytes:1285258 (1.2 MiB)

Restart the service to activate the new ip address
[root@station9 ~]# service network restart
[root@station9 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:13:20:B7:1D:44
inet addr:192.168.0.9 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::213:20ff:feb7:1d44/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:48173 errors:4 dropped:0 overruns:0 frame:4
TX packets:22001 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:39514528 (37.6 MiB) TX bytes:1720864 (1.6 MiB)
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:1249 errors:0 dropped:0 overruns:0 frame:0
TX packets:1249 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0
RX bytes:1285258 (1.2 MiB) TX bytes:1285258 (1.2 MiB)
[root@station9 ~]# netconfig --device eth0:1
[root@station9 ~]# service network restart
[root@station9 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:13:20:B7:1D:44
inet addr:192.168.0.9 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::213:20ff:feb7:1d44/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:48749 errors:4 dropped:0 overruns:0 frame:4
TX packets:22678 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:39873471 (38.0 MiB) TX bytes:1802196 (1.7 MiB)
eth0:1 Link encap:Ethernet HWaddr 00:13:20:B7:1D:44
inet addr:192.168.1.9 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 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:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
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:1249 errors:0 dropped:0 overruns:0 frame:0
TX packets:1249 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0
RX bytes:1285258 (1.2 MiB) TX bytes:1285258 (1.2 MiB)
To set or view the network parameters.
[root@station9 ~]# ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: Yes Speed: 100Mb/s
Duplex: Full
Port: MII
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: g
Wake-on: g
Current message level: 0x00000007 (7) Link detected: yes
[root@station9 ~]# ifup eth0
[root@station9 ~]# ifdown eth0
[root@station9 ~]# cd /etc/sysconfig/network-scripts/ [root@station9 network-scripts]# ls
ifcfg-eth0 ifdown-isdn ifup-ipsec ifup-routes
ifcfg-eth0:1 ifdown-post ifup-ipv6 ifup-sit
ifcfg-lo ifdown-ppp ifup-ipx ifup-sl
ifdown ifdown-sit ifup-isdn ifup-wireless
ifdown-aliases ifdown-sl ifup-plip init.ipv6-global
ifdown-ippp ifup ifup-plusb network-functions
ifdown-ipsec ifup-aliases ifup-post network-functions-ipv6
ifdown-ipv6 ifup-ippp ifup-ppp
[root@station9 network-scripts]# cat ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.9
NETMASK=255.255.255.0
GATEWAY=192.168.0.254
To set the hostname temporarily
[root@station9 ~]# hostname station9.example.com
To view the hostname
[root@station9 ~]# hostname station9.example.com
Set hostname permanently
[root@station9 ~]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=station9.example.com
:wq!
Set ip address temporarily
[root@station9 ~]# ifconfig eth0 192.168.0.9 netmask 255.255.255.0 View the interfaces.
[root@station9 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:13:20:B7:1D:44
inet addr:192.168.0.9 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::213:20ff:feb7:1d44/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:48153 errors:4 dropped:0 overruns:0 frame:4
TX packets:21992 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:39512670 (37.6 MiB) TX bytes:1720318 (1.6 MiB)
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:1249 errors:0 dropped:0 overruns:0 frame:0
TX packets:1249 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0
RX bytes:1285258 (1.2 MiB) TX bytes:1285258 (1.2 MiB)
Set permanent ip address
[root@station9 ~]# netconfig[root@station9 ~]# service network restart
[root@station9 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:13:20:B7:1D:44
inet addr:192.168.0.9 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::213:20ff:feb7:1d44/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:48173 errors:4 dropped:0 overruns:0 frame:4
TX packets:22001 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:39514528 (37.6 MiB) TX bytes:1720864 (1.6 MiB)
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:1249 errors:0 dropped:0 overruns:0 frame:0
TX packets:1249 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0
RX bytes:1285258 (1.2 MiB) TX bytes:1285258 (1.2 MiB)
[root@station9 ~]# netconfig --device eth0:1
[root@station9 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:13:20:B7:1D:44
inet addr:192.168.0.9 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::213:20ff:feb7:1d44/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:48749 errors:4 dropped:0 overruns:0 frame:4
TX packets:22678 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:39873471 (38.0 MiB) TX bytes:1802196 (1.7 MiB)
eth0:1 Link encap:Ethernet HWaddr 00:13:20:B7:1D:44
inet addr:192.168.1.9 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 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:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
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:1249 errors:0 dropped:0 overruns:0 frame:0
TX packets:1249 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0
RX bytes:1285258 (1.2 MiB) TX bytes:1285258 (1.2 MiB)
To set or view the network parameters.
[root@station9 ~]# ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: Yes Speed: 100Mb/s
Duplex: Full
Port: MII
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: g
Wake-on: g
Current message level: 0x00000007 (7) Link detected: yes
[root@station9 ~]# ifup eth0
[root@station9 ~]# ifdown eth0
[root@station9 ~]# cd /etc/sysconfig/network-scripts/ [root@station9 network-scripts]# ls
ifcfg-eth0 ifdown-isdn ifup-ipsec ifup-routes
ifcfg-eth0:1 ifdown-post ifup-ipv6 ifup-sit
ifcfg-lo ifdown-ppp ifup-ipx ifup-sl
ifdown ifdown-sit ifup-isdn ifup-wireless
ifdown-aliases ifdown-sl ifup-plip init.ipv6-global
ifdown-ippp ifup ifup-plusb network-functions
ifdown-ipsec ifup-aliases ifup-post network-functions-ipv6
ifdown-ipv6 ifup-ippp ifup-ppp
[root@station9 network-scripts]# cat ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.9
NETMASK=255.255.255.0
GATEWAY=192.168.0.254
No comments:
Post a Comment