-
Notifications
You must be signed in to change notification settings - Fork 49
Configuring NAT for the Linux Virtual Platform
This guide describes how to configure NAT to work with nSIM-based ARC Linux Virtual Platform. It is assumed that your host is an Ubuntu-based system with UFW (Uncomplicated firewall). For other Linux distributions search for the answers in the Internet.
This guide is based on https://help.ubuntu.com/14.04/serverguide/firewall.html
First, packet forwarding needs to be enabled in ufw. Two configuration files will need to be adjusted, in /etc/default/ufw change the DEFAULT_FORWARD_POLICY to “ACCEPT”:
DEFAULT_FORWARD_POLICY="ACCEPT"
Then edit /etc/ufw/sysctl.conf and uncomment:
net/ipv4/ip_forward=1
Similarly, for IPv6 forwarding uncomment:
net/ipv6/conf/default/forwarding=1
Now we will add rules to the /etc/ufw/before.rules file. The default rules only configure the filter table, and to enable masquerading the nat table will need to be configured. Add the following to the top of the file just after the header comments:
# nat Table rules
*nat
:POSTROUTING ACCEPT [0:0]
# Forward traffic from eth1 through eth0.
-A POSTROUTING -s 192.168.218.0/24 -o eth0 -j MASQUERADE
# don't delete the 'COMMIT' line or these nat table rules won't be processed
COMMIT
In the above example replace eth0 with the appropriate interface for your network.
Finally, disable and re-enable ufw to apply the changes:
sudo ufw disable && sudo ufw enable
Set default gateway:
[ARCLinux]$ route add default gw 192.168.218.1 eth0
To set default nameserver open /etc/resolv.conf and insert there:
nameserver 8.8.8.8
nameserver 8.8.4.4
Those are DNS server provided by Google (https://developers.google.com/speed/public-dns/docs/using), you can use your own DNS server.
It is recommended that you reload UFW configuration before starting SystemC mode