• Home
  • NW
  • Kultúra
  • Šport
  • Fun
  • Linux
  • Download

Asus A6TC

  • Ubuntu 8.04
  • Gigabit LAN
  • Disk

Network

  • IP config
  • Firewall
  • SSH tunnel
  • TIPS
  • SSH tunnel advanced

Server basics

  • LVM with EXT3

Linky kámošov

  • Sacie-komando

Linky školy

  • Diplomovka
  • STU FEI KTL
  • STU FEI

Linky in-line

  • Zakkaz
  • Be-mag

Na pobavenie

  • Najstaršia stránka
LINUX » IP

Basic IP configuration

The examined expample is to set up on ubuntu box IP address 192.168.1.38 with mask 255.255.255.0 and gateway 192.168.1.1. I set it up on the gigabit interface, which system knows as eth0. For this we use ip , for checking that everything is working corectly same commands with different parameter is used. This changes to system will disappear after restart of network service. Distributions based on later kernels have deprecated ifconfig, route, and ipchains , replacing them with iptables and iproute2. iproute2 includes support for all that ifconfig(8) and route(8) do, as well as traffic-control (such as bandwidth-shaping).

Setting ip and gateway address with ip command:
root@roleta:~# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:18:f3:8f:d7:bc brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.33/24 brd 192.168.1.255 scope global eth0
    inet6 fe80::218:f3ff:fe8f:d7bc/64 scope link 
       valid_lft forever preferred_lft forever
3: wmaster0: <BROADCAST,MULTICAST> mtu 1500 qdisc ieee80211 qlen 1000
    link/ieee802.11 00:18:f3:66:1d:b3 brd ff:ff:ff:ff:ff:ff
4: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:18:f3:66:1d:b3 brd ff:ff:ff:ff:ff:ff
root@roleta:~# ip addr del 192.168.1.33/24 dev eth0
root@roleta:~# ip addr add 192.168.1.38/255.255.255.0 dev eth0 
root@roleta:~# ip route add 0.0.0.0/0 via 192.168.1.1
root@roleta:~# ip addr show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:18:f3:8f:d7:bc brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.38/24 scope global eth0
    inet6 fe80::218:f3ff:fe8f:d7bc/64 scope link 
       valid_lft forever preferred_lft forever
root@roleta:~# ip route list
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.38 
default via 192.168.1.1 dev eth0 
root@roleta:~# netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth0
root@roleta:~# ping www.google.sk
PING www.l.google.com (209.85.129.147) 56(84) bytes of data.
64 bytes from fk-in-f147.google.com (209.85.129.147): icmp_seq=1 ttl=245 time=25.4 ms
64 bytes from fk-in-f147.google.com (209.85.129.147): icmp_seq=2 ttl=245 time=24.3 ms

--- www.l.google.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 24.344/24.899/25.454/0.555 ms
root@roleta:~# 
Setting ip in Linux based on kernel 2.2.x:
root@roleta:/# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:18:f3:8f:d7:bc  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:3435 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3569 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2900730 (2.7 MB)  TX bytes:640443 (625.4 KB)
          Interrupt:21 Base address:0xe000 

root@roleta:/# ifconfig eth0 192.168.1.38 netmask 255.255.255.0 broadcast 192.168.1.255 up
root@roleta:/# route add default gw 192.168.1.1 eth0
root@roleta:/# netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth0
root@roleta:/# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0
ifconfig eth0
default         192.168.1.1     0.0.0.0         UG    0      0        0 eth0
root@roleta:/# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:18:f3:8f:d7:bc  
          inet addr:192.168.1.38  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::218:f3ff:fe8f:d7bc/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3455 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3649 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2902913 (2.7 MB)  TX bytes:651906 (636.6 KB)
          Interrupt:21 Base address:0xe000 

root@roleta:/# ping www.google.com
PING www.l.google.com (74.125.39.99) 56(84) bytes of data.
64 bytes from fx-in-f99.google.com (74.125.39.99): icmp_seq=1 ttl=245 time=31.7 ms
64 bytes from fx-in-f99.google.com (74.125.39.99): icmp_seq=2 ttl=245 time=32.4 ms

64 bytes from fx-in-f99.google.com (74.125.39.99): icmp_seq=3 ttl=245 time=32.4 ms
64 bytes from fx-in-f99.google.com (74.125.39.99): icmp_seq=4 ttl=245 time=32.1 ms

--- www.l.google.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2999ms
rtt min/avg/max/mdev = 31.766/32.202/32.457/0.302 ms
root@roleta:/# 

For persistance changes to network configuration the network configuration file need to be changed. It depends on linux distribution.

Permanent IP configuration

Configuration file /etc/network/interfaces need to be changed to make permanent changes to IP configuration of Ubuntu box. After these changes shown in next are set, network service need to be restarted. After next restart of this service, or reboot, the IP address remain chenged.

Permanent setting of static ip and gateway address in configuration file /etc/network/interfaces:
root@roleta:/etc/network# cat /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.1.38
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
root@roleta:/etc/network# /etc/init.d/networking restart
 * Reconfiguring network interfaces...                                                                                                               [ OK ] 
root@roleta:~# ip addr show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:18:f3:8f:d7:bc brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.38/24 scope global eth0
    inet6 fe80::218:f3ff:fe8f:d7bc/64 scope link 
       valid_lft forever preferred_lft forever
root@roleta:~# ip route list
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.38 
default via 192.168.1.1 dev eth0 
root@roleta:/etc/network# ping www.google.sk
PING www.l.google.com (74.125.39.147) 56(84) bytes of data.
64 bytes from fx-in-f147.google.com (74.125.39.147): icmp_seq=1 ttl=245 time=31.4 ms
64 bytes from fx-in-f147.google.com (74.125.39.147): icmp_seq=2 ttl=245 time=31.5 ms

--- www.l.google.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 31.498/31.516/31.535/0.178 ms
root@roleta:/etc/network# 

Dns configuration

Not using DHCP as service for obtain network configuration, DNS server need to be set. For doing it, just edit DNS configuration file also depending on linux distribution. For Ubuntu it is /etc/resolv.conf. I had set up DNS server of mine ISP with address 195.168.1.2. For checking everything is working correctly use command nslookup.

For setting DNS use vi to edit file /etc/resolv.conf:
root@roleta:/etc/network# cat /etc/resolv.conf
nameserver 195.168.1.2
root@roleta:/etc/network# /etc/init.d/networking restart
 * Reconfiguring network interfaces...                                                                                                               [ OK ] 
root@roleta:/etc/network# host www.google.sk
www.google.sk is an alias for www.google.com.
www.google.com is an alias for www.l.google.com.
www.l.google.com has address 74.125.39.103
www.l.google.com has address 74.125.39.104
www.l.google.com has address 74.125.39.147
www.l.google.com has address 74.125.39.99
root@roleta:/etc/network# nslookup www.google.sk
Server:        195.168.1.2
Address:    195.168.1.2#53

Non-authoritative answer:
www.google.sk    canonical name = www.google.com.
www.google.com    canonical name = www.l.google.com.
Name:    www.l.google.com
Address: 74.125.39.104
Name:    www.l.google.com
Address: 74.125.39.147
Name:    www.l.google.com
Address: 74.125.39.99
Name:    www.l.google.com
Address: 74.125.39.103

root@roleta:/etc/network# 

Some content copyright © 2008 find on facebook , some rights reserved, feel free to share "opensource" way of thinking. Layout created at CSSWebLayouts
Legal | Privacy Policy | Contact