2

I'm setting up a NAT, and need to assign a static IP to my eth1 interface. The problem is that once in a while, it resets, and I need to run the following command again:

sudo ifconfig eth1 192.168.47.1 netmask 255.255.255.0

I was wondering if I can hardcode this static IP to this interface. Probably there should be a file which we would just need to modify, or so?

angel_30
  • 303

1 Answers1

2

If you are using Ubuntu Desktop, you can use Network Manager to configure the static IP address. For Ubuntu server (or manual configuration on Ubuntu Desktop), you can edit the /etc/network/interfaces file:

sudo nano /etc/network/interfaces

And add the following content:

auto eth1
iface eth1 inet static
    address 192.168.47.1
    netmask 255.255.255.0

You can apply the settings by restarting the networking service:

sudo service networking restart
jkt123
  • 3,530
  • 22
  • 24