A site for solving at least some of your technical problems...
A site for solving at least some of your technical problems...
(click on image to see 4K version in new window)
I just received my Jetson TX2 so I had to test it!
First I needed to setup the network since by default it wants DHCP which I don't allow by default on my server.
Since it's running Ubuntu, I thought it would be dead easy, but I ran in two interesting settings I hadn't seen before.
When you are about to edit an interface, you probably want to first bring it down. If you forget to do this step first, you may have to reboot to get the status back to normal. So run this one:
sudo ifdown eth0
You may want to verify that your interface is indeed eth0 and not somthing else. I would imagine that all Jetson cards use eth0, but it may change in the future. I have another computer that uses p4p1, for example.
You can see the list of available network cards using ifconfig.
Note: newer boards may use netplan instead of the if interface. In that case, you do not need to take it down first. You just edit the netplan YAML file and run an update.
First, you want to edit the interface file named eth0 as follow:
sudo vim /etc/network/interfaces.d/eth0
Note 1: The default root password (when you use sudo you become root) is nvidia for the nvidia user (although you should change it if you don't setup your board behind a strong firewall!)
Note 2: Newer boards do not have a default password, instead they force you to create your own account and enter a password at that point. This is much safer. If you get an older board model, you probably still have to go to the new process (old boards support new software). Although I liked the old scheme, the new scheme is definitely much safer but it comes at a cost: your very first boot needs to be without a network connection (at least for me it caused problems on an AGX).
Inside the file, enter the usual info so eth0 gets setup with a static IP address:
auto eth0 iface eth0 inet static address 10.1.1.2 netmask 255.255.255.0 network 10.1.1.0 broadcast 10.1.1.255 gateway 10.1.1.1 dns-nameservers 8.8.8.8 dns-search m2osw.com
You want to change the 10.1.1.2 and other IPs with your LAN IPs, obviously.
Up to here... nothing too bad outside of the fact that it was in a sub-directory in a file named eth0. (I saw that before, it's just the first time I had to deal with this in this way. Usually I just edited the /etc/network/interfaces file directly.)
Okay, to have the new IP taken in account, we have to restart the network interface, the opposite of the ifdown we ran earlier:
sudo ifup eth0
Now you've got the correct IP address. You can verify that with ifconfig:
nvidia@tegra-ubuntu:~$ ifconfig eth0 Link encap:Ethernet HWaddr 12:34:56:78:9a:bc inet addr:10.1.1.2 Bcast:10.1.1.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:185198 errors:0 dropped:0 overruns:0 frame:0 TX packets:98299 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:273767068 (273.7 MB) TX bytes:7816016 (7.8 MB) Interrupt:42
As we can see, the inet addr field has the IP address as defined in our edits.
On newer versions you can use the ip command like so:
nvidia:~$ ip address
This gives you a list of configured interface slightly different from the ifconfig command, but the content is the same. This is becoming the preferenced command to see your interfaces.
To verify the gateway, use the route command:
nvidia:~$ route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default 10.1.1.1 0.0.0.0 UG 0 0 0 eth0 link-local * 255.255.0.0 U 1000 0 0 eth0 10.1.1.0 * 255.255.255.0 U 0 0 0 eth0
We see that the default destination has the Gateway IP address we defined in our eth0 interface file and the Flags say "UG" (the 'U' stands for Up and the 'G' stands for Gateway, for more info, check out the manual page: man route).
Notice that there is an Iface column that says the Gateway is on eth0.
The ip command can also be used to see the routes. The output is not shown in a table with nice columns, but in most cases the number of routes is pretty limited so it's rarely an issue.
nvidia:~$ ip route
Note that you can also access the different route lists or all the lists this way:
nvidia:~$ ip route list table all
Now this command may output many entries. Instead of "all" you can list each individual table. Checkout the help to have a more complete list of route options:
nvidia:~$ ip route help
and use the manual to get more details. It has beena long time since I had to tweak routes on my own. 99.99% of the time, the Linux system figures it out properly so you hardly ever have to do anything about these.
Now we're probably interested by the Internet... can we access the Internet?
I will assume that your Gateway computer is correctly setup. If you have an intermediate computer, you'll need to have the FORWARD and POSTROUTING correctly defined in your Linux firewall. Also, if you're like me, you'll have to "pierce" a hole in your firewall so the IP address you just assigned to your Jetson works as expected.
What I do to test whether I can access the Internet, is to test the DNS system. To do that, I simple ping an IP address by hostname. For example:
ping www.ibm.com
IBM may or may not allow the ping itself, but at least you should see the hostname www.ibm.com replaced with an IP address. When I tried today, I got this one:
PING e2874.dscx.akamaiedge.net (184.27.110.73) 56(84) bytes of data.
Please hit Ctrl-C quickly to not abuse the ping system offered by IBM or any other company (unless you have your own DNS servers and can ping your own servers.)
Chances are, that won't work first time on Jetson TX1 or Jetson TX2.
ping: unknown host www.ibm.com
What you need to do is help the OS with the nameserver resolution. Somehow, it does not work out of the box. All I had to do to fix this was to create the /etc/resolv.conf file with:
sudo vim /etc/resolv.conf
You actually probably saw a warning about that file missing when you ran the ifup and ifdown commands:
grep: /etc/resolv.conf: No such file or directory
Okay, now that you are editing the resolv.conf file, type your name servers there instead (that is, it's probably not necessary in the /etc/network/interfaces.d/eth0 file, although I would suggest you leave it in both places.) Like me, enter a couple of DNS entries:
nameserver 8.8.8.8 nameserver 8.8.4.4
These are from Google. If you have others from your Internet Provider, you may want to use theirs. The Google DNS server is probably further away from you, so it's not a bad idea to your use Internet Provider IPs. If you're at work, ask your IT guy what DNS IPs you should be using or check your other computer(s) and reuse those IPs.
Save this file and now you're ready to rock. Try the ping as shown above and you should see the hostname converted to a corresponding IP address. If so, you're connected to the Internet via a static IP address.
My point of view is that with a static IP address there is no guessing. You can write scripts that directly access your device and make it work as expected.
The DHCP networking protocol introduces some latency that doesn't exist at all with a static IP. Also once in a while you lose the IP address for some time. Usually the IP is renewed before it goes out of business, but if for whatever reason that renewal doesn't work, then you're hosed!
Finally, if you want to setup a strong firewall, a DHCP system means any one of your computer that access the network using DHCP may end up with any one of the allowed DHCP IP address. This means that the firewall has to be "wide open" in a similar way for all the computers using DHCP.
Although, obviously, you can force a specific IP address even with DHCP, which I do for my WiFi devices. For example, my Jetson could have been setup using an entry like this in my /etc/dhcp/dhcpd.conf file:
host jetson_tx2 { next-server jetson.example.com; hardware ethernet 12:34:56:78:9a:bc; fixed-address 10.1.1.2; }
You will have to replace the IP address on the fixed-address field and for the DHCP to make that selection, it uses the MAC address which is defined by the hardware ethernet field.
Note that in most cases the MAC address will have 2 or 4 other numbers to the left. Often it looks like 00:80 or something like that. Just use the last 6 numbers. These are always Hexadecimal numbers. The letters are case insensitive.
To find the MAC address when you have access to a computer, use the ifconfig command. It will display the MAC as the hardware address:
eth0 Link encap:Ethernet HWaddr 12:34:56:78:9a:bc
The numbers after the HWaddr are those you are interested in.
From the system where you are setting up the DHCP, you can find the hardware IP address in the arp file as follow:
my-computer $ cat /proc/net/arp IP address HW type Flags HW address Mask Device ... 10.1.1.2 0x1 0x2 12:34:56:78:9a:bc * eth4 ...
(the ... represents other entries removed here to keep my own network top secret!)
We recognize the exact same HW address field.
See Also: Playing a video with your Jetson TX1/TX2 from the command line