Skip to content

2.2 Network: Internet and port forwarding

nongiach edited this page Jun 5, 2018 · 1 revision

Internet connection

By default arm_now has a nat network interface already configured.

$ arm_now start armv5-eabi
# ip a 
1: lo: <LOOPBACK> mtu 65536 qdisc noop qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/8 brd 10.255.255.255 scope global eth0
       valid_lft forever preferred_lft forever
# wget google.com
--2018-06-04 23:36:38--  http://google.com/
Resolving google.com... 216.58.206.238, 2a00:1450:4007:817::200e
Connecting to google.com|216.58.206.238|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.google.com/ [following]
--2018-06-04 23:36:38--  http://www.google.com/
Resolving www.google.com... 216.58.213.196, 2a00:1450:4005:803::2004
Connecting to www.google.com|216.58.213.196|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4657 (4.5K) [text/html]
Saving to: 'index.html'

index.html          100%[===================>]   4.55K  --.-KB/s    in 0.001s  

2018-06-04 23:36:38 (7.30 MB/s) - 'index.html' saved [10680]

Port forwarding

In this example the tcp port 8080 of the host is redirected to the guest port 80.

arm_now start --redir tcp:8080::80
# opkg install netcat
# netcat -l -vv -p 80
Listening on any address 80 (www)
Connection from 10.0.2.2:49374
GET / HTTP/1.1
Host: 0:8080
User-Agent: curl/7.59.0
Accept: */*

What else do you need?

In the meantime on the host

$ curl 0:8080
What else do you need?

Download a file from the host

From the host

$ ip --brief a
lo               UNKNOWN        127.0.0.1/8 ::1/128 
enp0s3           UP             192.168.0.18/24 fe80::8531:bbd5:4c43:ee97/64 
$ echo arm_now_is_awesome > secret
$ python3 -m http.server

From the guest

$ arm_now start
press ctrl+] to kill qemu
Welcome to arm_now
buildroot login: root
# wget http://192.168.0.18:8000/secret
secret              100%[===================>]      19  --.-KB/s    in 0s      
2018-06-05 00:03:26 (142 KB/s) - 'secret' saved [19/19]
# cat secret
arm_now_is_awesome
# # Here is a little qemu tips for you:
# wget http://10.0.2.2:8000/secret