User Tools

Site Tools


kb:ni-rt:linuxrt:network

06 Network

Basic Commands

Display Network Settings

  ifconfig

If the command does not work, it's worth trying sudo -u admin ifconfig.

See below for ifconfig example output.

Display Routes

  route

See below for route example output.

View Config File

The current network settings can be viewed directly from the ''ni-rt.ini'' configuration file. It should contain one section per network interface, similar to the following output

[ETH0]
dhcpipaddr=192.168.0.200
dhcpenabled=0
linklocalenabled=0
IP_Address=192.168.0.1
Subnet_Mask=255.255.255.0
Gateway=192.168.0.1
DNS_Address=192.168.0.1
Mode=TCPIP
MediaMode=Auto

For static IP address settings, dhcpenable and linklocalenable need to be set to 0.

Set Persistent IP Address

IP-address change. Static and persistent. From shell/SSH

  nirtcfg --set section=ETH0,token=ip_address,value=192.168.1.5
  nirtcfg --set section=ETH0,token=subnet_mask,value=255.255.255.0
  nirtcfg --set section=ETH0,token=gateway,value=192.168.1.1
  /etc/init.d/networking restart

Advanced Settings

A new route added with route or ip route is not persistent. To create a persistent route that is added with every restart, create a new file (e.g. “add-routes”) in /etc/network/if-up.d and insert the add route command:

ip route add {NETWORK} via {IP} dev {DEVICE}

Make the script executable with chmod +x {filename}.


Example Output

ifconfig

admin@cRIO9030:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:80:2F:25:9B:64  
          inet addr:10.21.31.213  Bcast:10.21.31.255  Mask:255.255.255.0
          inet6 addr: fe80::280:2fff:fe25:9b64%4738680/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3194 errors:0 dropped:0 overruns:0 frame:0
          TX packets:211 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:208850 (203.9 KiB)  TX bytes:45619 (44.5 KiB)
          Memory:d0900000-d097ffff 

eth1      Link encap:Ethernet  HWaddr 00:80:2F:25:9B:65  
          UP BROADCAST 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)
          Memory:d0800000-d087ffff 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1%4738680/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:197 errors:0 dropped:0 overruns:0 frame:0
          TX packets:197 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:16174 (15.7 KiB)  TX bytes:16174 (15.7 KiB)

usb0      Link encap:Ethernet  HWaddr 00:80:2F:25:9B:66  
          UP BROADCAST 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)

admin@cRIO9030:~# 

route

admin@TEST-LOGGER2-cRIO9030:~# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         10.21.31.10     0.0.0.0         UG    10     0        0 eth0
10.21.31.0      *               255.255.255.0   U     0      0        0 eth0
169.254.0.0     *               255.255.0.0     U     100    0        0 eth0
admin@TEST-LOGGER2-cRIO9030:~# 

kb/ni-rt/linuxrt/network.txt · Last modified: 2020/06/18 18:31 by manuel.sebald